I am trying to create a JSON output with php and when I output the result, I am getting numbers that I don’t have in my DB.
Here’s my php code:
<?php
mysql_select_db("mark1", $link);
$result = mysql_query("SELECT * FROM `Movies` LIMIT 0, 30 ");
while($row = mysql_fetch_array($result))
{
$output[]=$row;
}
print(json_encode($output));
?>
Heres’ the output:
[{"0":"58","id":"58","1":"test","title":"test","2":"test","actors":"test","3":"G","rating":"G"}]
Where is 0, 1, 2, 3 coming from?
Replace
$row = mysql_fetch_array($result)with$row = mysql_fetch_assoc($result).mysql_fetch_array() returns array also which is giving these 0, 1, 2, 3 indexes