2
我想傳遞一個JSON數組中的類別的子類別通過JSON PHP
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代碼