时间:2021-07-01 10:21:17 帮助过:18人阅读

$sqlstr = "select * from table where id<6";
$query = mysql_query($sqlstr) or die(mysql_error());
while($thread=mysql_fetch_array($query)){
$result[] = $thread;
}
print_r($result);
建议一开始建立表结构的时候考虑下无限级分类;然后把你这个表好好优化下那样获取就更好了。select cate1, group_concat(cate2) as cate2 from tbl_name where cate2!='' group by cate1 order by id
cate1 cate2
Protect Power Bank Protectio,Table Protection,Phone Case
Power Wall Charger,Car Charger,Power Bank
Keyboard&Mouse Mouse,Keyboard
Headphone Bluetooth Headphone,Earphone,Headphone
Bluetooth_Speaker Wall Charger,Car Charger,Power Bank