在经历了这里提供的一些解决方案后,我仍然无法得到正确的结果。当我将鼠标悬停在类别名称上时,只会从数据库中获取并显示最后一个类别的子类别。
<div class="mega-menu-category">
<ul class="nav">
<!-- Other side-menu navs -->
<?php $sql=mysqli_query($con,"SELECT id,categoryName FROM category");
while($row=mysqli_fetch_array($sql))
{
?>
<li><a href="category.php?cid=<?php echo $row['id'];?>"><?php echo $row['categoryName'];?></a>
<?php
$getid = $row['id'];
}?>
<div class="wrap-popup column1">
<div class="popup">
<?php $sql=mysqli_query($con,"SELECT id, subcategory FROM subcategory WHERE categoryid= '$getid'");
while($row=mysqli_fetch_array($sql))
{
?>
<ul class="nav">
<li><a href="sub-category.php?scid=<?php echo $row['id'];?>"><?php echo htmlentities($row['subcategory']);?></a></li>
</ul>
<?php } ?>
</div>
</div>
</li>
<!-- used one -->
</ul>
</div>
慕神8447489