我当前的 PHP 代码是:
<?php
//$name = $_POST['name'];
$sql = "select * from SocietyDatabase WHERE Name='Badminton'";
$result = mysql_query($sql);
$json = array();
if(mysql_num_rows($result))
{
while($row=mysql_fetch_row($result))
{
$json['info'][]=$row;
}
}
echo json_encode($json);
?>
结果是:
{"info":[["SOC003","Badminton","Sport","Me","You","me@gmail.com","badminton society"]]}
但我希望它采用这种带有“标题”的格式:
{"earthquakes": [
{
"eqid": "c0001xgp",
"magnitude": 8.8,
"lng": 142.369,
"src": "us",
"datetime": "2011-03-11 04:46:23",
"depth": 24.4,
"lat": 38.322
}
]}
那么我该如何实现呢?谢谢