Export MySQL to Json: Difference between revisions
Jump to navigation
Jump to search
Kaplanerkan (talk | contribs) No edit summary |
Kaplanerkan (talk | contribs) |
||
Line 32: | Line 32: | ||
== Parse the Result == | == Parse the Result == | ||
<pre> | |||
Function Button1_onclick() | |||
$.getJSON("datas.json", gotResult) | |||
End Function | |||
Function gotResult(data) | |||
Dim speisen=[] | |||
For i=0 To 10 | |||
speisen[i]=[String(data[i].Menue),String(data[i].Text_D)] | |||
Next | |||
End Function | |||
'JavaScript | |||
' var speisen=[]; | |||
' $.getJSON("datas.json", function(data) { | |||
' var i=0; | |||
' for (i=0; i<10; i++){ | |||
' speisen[i]=[String(data[i].Menue),String(data[i].Text_D)]; | |||
' } | |||
' }); | |||
'End JavaScript | |||
' ANOTHER METHODS | |||
'JavaScript | |||
'$.getJSON( "datas.json", function(data) { | |||
' var items = []; | |||
' $.each( data, function( key, val ) { | |||
' items.push( "<li id='" + key + "'>" + val + "</li>" ); | |||
' }); | |||
' | |||
' $( "<ul/>", { | |||
' "class": "my-new-list", | |||
' html: items.join( "" ) | |||
' }).appendTo( "body" ); | |||
'}); | |||
' | |||
' | |||
'End JavaScript | |||
</pre> |
Revision as of 13:35, 4 October 2013
SET SESSION group_concat_max_len = 100000000; SELECT CONCAT("[", GROUP_CONCAT( CONCAT("{ \"Menue\": \" ", Menue , " \" "), CONCAT(", \"Text_D\": \" ", Text_D), " \"}") ,"]") AS json FROM menu ;
Datas.json
[ {"Menue":"1", "TextD":"Sake"}, {"Menue":"2", "TextD":"Maguro"}, {"Menue":"3", "TextD":"Mutsu"}, {"Menue":"4", "TextD":"Izumidai"}, {"Menue":"5", "TextD":"Amaebi"}, {"Menue":"6", "TextD":"Ebi"}, {"Menue":"7", "TextD":"Kanikama"}, {"Menue":"8", "TextD":"Avocado"}, {"Menue":"9", "TextD":"Tamago"} ]
Parse the Result
Function Button1_onclick() $.getJSON("datas.json", gotResult) End Function Function gotResult(data) Dim speisen=[] For i=0 To 10 speisen[i]=[String(data[i].Menue),String(data[i].Text_D)] Next End Function 'JavaScript ' var speisen=[]; ' $.getJSON("datas.json", function(data) { ' var i=0; ' for (i=0; i<10; i++){ ' speisen[i]=[String(data[i].Menue),String(data[i].Text_D)]; ' } ' }); 'End JavaScript ' ANOTHER METHODS 'JavaScript '$.getJSON( "datas.json", function(data) { ' var items = []; ' $.each( data, function( key, val ) { ' items.push( "<li id='" + key + "'>" + val + "</li>" ); ' }); ' ' $( "<ul/>", { ' "class": "my-new-list", ' html: items.join( "" ) ' }).appendTo( "body" ); '}); ' ' 'End JavaScript