mysql table
ID >> Name >> Salary
$row_set << database table information.
my problem is when i use
json_encode($row_set);
the output will be something like this:
[{"0":"1","ID":"1","1":"x","Name":"x","2":"12345","Salary":"12345"}]
i want the results to be something like this
[{"ID":"1","Name":"x","Salary":"12345"}]
how to do that ?
EDIT :: FULL CODE
$result = mysql_query("SELECT * FROM emp");
while($row = mysql_fetch_array($result))
{
$row_set[] = $row;
}
echo json_encode($row_set);
I presume you are using
mysql_fetch_arrayto get the row at the moment.Try
mysql_fetch_array($resource, MYSQL_ASSOC)(note the 2nd parameter!)or
mysql_fetch_assoc().