I have a navigation which is dynamically set through database. I have a category and subcategory table. I have arranged my navigation bar with category table and using its foreign key when i hover over category it shows it's subcategories.It is working correctly! I have given a input value with both category and subcategory which is hidden and it consist of cat_id
and s_cat_id
.Both are primary keys of category table and subcategory table. Now i am trying to access id's when i click on any of the hover list. I am stuck here. Any suggestions will be highly appreciated!
Code
<ul id="nav">
<?php
$res=mysqli_query($con,"SELECT * FROM category");
while($row=mysqli_fetch_array($res))
{
?>
<li>
<li> <a href="<?php echo "index.php?page=".$row1['s_cat_name']."&s_cat_id=".$row1['s_cat_id']; ?>"><?php echo $row1['s_cat_name'];?></a></li>
<ul>
<?php
$result=mysqli_query($con,"SELECT * FROM subcategory WHERE cat_id=".$row['cat_id']);
while($row1=mysqli_fetch_array($result))
{
?>
<li> <a href="<?php echo "index.php?mode=2&page=".$row1['s_cat_name']; ?>"><?php echo $row1['s_cat_name'] ?><input type="" name="s_cat_id" value="<?php echo $row1['s_cat_id'] ?>"></a></li>
<?php
}
?>
</ul>
</li>
<?php
}
?>