Reputation: 841
I have the following codewhich basically seems to be overwriting the same array each time so the output (json) only gives me the last row returned?
Thanks
$structure = mysql_query("SELECT FIELDNAME, DISPLAYNAME from `_PREFS_MAINGRID_`");
$rowsField = array();
while($struct = mysql_fetch_assoc($structure)) {
$rowsField["columname"] = $struct;
}
$plode = implode("` as `", $rowsField["columname"]);
print json_encode($rowsField);
Upvotes: 0
Views: 98
Reputation: 76636
You aren't pushing the elements into the array in your loop.
Try this:
$rowsField["columname"][] = $struct;
See the documentation for more information.
Upvotes: 4