I have the following PHP code:
$data=mysql_query("SELECT * FROM notes WHERE rootNoteId='$noteId'");
$mainArray;
while($result = mysql_fetch_array($data))
{
$mainArray[]=$result;
}
$sendback = array(
"mainArray" => $mainArray
);
sendResponse(200, json_encode($sendback));
My table 'notes' has the following fields:
'noteId'
'authorName'
'noteBody'
However my return JSON string has the following format:
{
"0": "3",
"1": "Moe Bit",
"2": "Sub sub ",
"noteId": "3",
"authorName": "Moe Bit",
"noteBody": "Sub sub "
}
Why is it adding 0,1,2 indexes for the array with duplicate values of my table fields? I just want noteId, authorName, and noteBody-I'm not sure where it's coming up with "0","1","2".