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_array
to get the row at the moment.
Try mysql_fetch_array($resource, MYSQL_ASSOC)
(note the 2nd parameter!)
or mysql_fetch_assoc()
.
精彩评论