我想以以下形式传递一个 json 数组
category_list: [
{category_name: ,
category_id: ,
subcategory_list: [
{subcategory_name: ,
subcategory_id: ,
subsubcategory_list:[
{subsubcategory_name: ,
subsubcategory_id: ,
subsubcategory_image: , },
]
},
]
}
]
我正在使用的 php 代码是
<?php
mysql_connect("localhost","abc","");
mysql_select_db("test");
$rows=mysql("SELECT categoryid FROM category");
while($numrows=mysql_fetch_assoc($rows))
{
$numcatid[]=$numrows;
for(i=0;i<=count($numcatid[]);i++)
{
$q=mysql_query("SELECT * FROM subcategory WHERE categoryid = $numrows");
while($e=mysql_fetch_assoc($q))
$output[]=$e;
json_encode($output[]);
}
}
$arrayofarray[]=$output[];
json_encode($arrayofarray[]);
mysql_close();
?>
请更正php代码