I have the following code:
//--------------------------------------------------------------------------
// 2) Query database for data
//--------------------------------------------------------------------------
$result = mysql_query("SELECT * FROM $tableName"); //query
$array = mysql_fetch_row($result); //fetch result
//--------------------------------------------------------------------------
// 3) echo result as json
//--------------------------------------------------------------------------
echo json_encode($array);
What I would like to do is fetch all rows based on the query and feed those into the array, to give me an output like this:
["1", "", "", "", "", ""]
["2", "", "", "", "", ""]
etc...
I presume I need to loop through the rows and build up the array but I don't know how.