0
I’m trying to produce a script that when I query in mysql it returns an array, so far ok, but the goal is to make this query turn into an edited json. Example:
{"changelog":{"count":2,"news":{"ola":"testando1","ola2":"testando2"}}}
And in C# I make a code that returns this and puts it in a Textbox. But I don’t know how to add an item in an array when returning the data in array.
$array1 = array();
while( $row = mysql_fetch_array($query)){
// adiciona no array a $row[1] e $row[2] por exemplo: no lugar do 'ola' fica o $row[1] e no lugar do 'testando1' fica o $row[2]
}
but the query we will assume is 30 items the query is limited to LIMIT 0,10
TABLE:
CAMPO | VALOR ID | TIPO INT, NOT NULL, AUTO INCREMENT TITLE | TIPO TEXT, NOT NULL // $row[1] DESCRIPTION | TIPO LONGTEXT, NOT NULL // $row[2]
ID | TITLE | DESCRIPTION 0 | ola | testando1 1 | ola2 | testando2
From what I understand, you want to create an array of arrays and encode in JSON, that’s it?
– Paul Polidoro
yes! after the news he will put
{"TITLE":"DESCRIPTION"}
until the mysql array is finished– FRNathan13
One more question,
{"changelog":{"count":2,"news":
these data are fixed?– Paul Polidoro
yes! changelog is the opening and Count is the mysql_num_rows
– FRNathan13