我已经创建了一个数据来自mysql数据库的菜单。菜单链接href如下:href = slider1.php?cat_id =" 。 $ row [' cat_id']。 "&安培;产物=" 。 $ row ['产品']。 "
菜单的数据库摘录
我的问题是:我能够获得第一级数据但是第二级和第三级数据,我无法显示。使用下面的PHP代码,我可以获得第一级
cat_id
。我不明白如何用下面的PHP代码获得二级和三级id。
<?php
include('include/config.php');
if(isset($_GET['cat_id']))
{
$level1= $_GET['cat_id'];
if($stmt = $connection->prepare("SELECT
a.img_id,
a.img_type,
a.img_size,
b.ad_id,
b.cus_id,
b.ad_name,
c.customer,
c.mobile,
d.product as category,
e.product as subcategory,
f.product as subcat
FROM `image` a
INNER JOIN `advt` b
ON a.ad_id=b.ad_id
INNER JOIN `customer` c
ON b.cus_id=c.cus_id
INNER JOIN `category` d
ON b.category = d.cat_id
INNER JOIN `category` e
ON b.subcategory = e.cat_id
INNER JOIN `category` f
ON b.subcat = f.cat_id AND d.cat_id = '$level1'
GROUP BY b.ad_id
")){
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($img_id, $img_type, $img_size, $ad_id, $cus_id, $ad_name, $customer, $mobile, $category, $subcategory, $subcat);
while($stmt->fetch()){
?>
<tr class="example">
<td><?php echo $ad_id; ?></td>
<td><?php echo $img_name; ?></td>
<td><?php echo $cus_id; ?></td>
<td><?php echo $ad_name; ?></td>
<td><?php echo $customer; ?></td>
<td><?php echo $mobile; ?></td>
<td><?php echo $category; ?></td>
<td><?php echo $subcategory; ?></td>
<td><?php echo $subcat; ?></td>
</tr>
<?php
}
$stmt->close();
}
}
?>