My php side
$i = 1;
while ($row = mysql_fetch_array($query)) {
$productarray[$i][] = $row['product_id'];
$productarray[$i][] = $row['product_model'];
$productarray[$i][] = $row['product_type'];
$productarray[$i][] = $row['product_return'];
$i++;
}
$jsonstring = json_encode($productarray);
This is what im getting Is this a valid json string
{
"1":["1","HFJ5G1.5","plat","graviteits"],
"2":["2","HHJ5S2.5","holle plunjer","veer"],
"3":["3","HTJ5S7.5","inbouw","veer"]
}
i cant iterate through this someone please tell me how to iterate this json
From the json site i think this is the format if so how can i change the above json string to this format ?
{
"1":[{"1","HFJ5G1.5","plat","graviteits"}],
"2":[{"2","HHJ5S2.5","holle plunjer","veer"}],
"3":[{"3","HTJ5S7.5","inbouw","veer"}]
}
You need to refactor your PHP code a tad bit. Try doing something like this:
Notice that it now becomes very easy to iterate. You can do so as follows: