I have two SQL queries that display different results from my database. I'm using these results as navigation links in my nav bar.
At the moment all the results display as a single line of text, I want to make each SQL query display as a drop down menu, with all the results from the query as an option in the drop down.
Here's the code I'm using:
<?php
$q = "SELECT cat_id, cat_name FROM Category";
$result = mysqli_query($_SESSION['conn'], $q);
while ($row = mysqli_fetch_row($result)) {
echo "<a href='category.php?id=$row[0]'>$row[1]</a> ";
//display product categories
}
mysqli_free_result($result); //free result
$q = "SELECT brand_id, brand_name FROM Brand";
$result = mysqli_query($_SESSION['conn'], $q);
while ($row = mysqli_fetch_row($result)) {
echo "<a href='brand.php?id=$row[0]'>$row[1]</a> ";
//display product Brands
}
?>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…