php menu generation problem
Posted: Tue Apr 08, 2008 3:20 pm
simple logic error in this menu
how can i prevent duplicate line entries from appearing for the same category (only once per under each heder)?
how can i prevent duplicate line entries from appearing for the same category (only once per under each heder)?
Code: Select all
<?PHP
$mysqli = new mysqli("localhost", "root", "****", "inventory");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
else {
echo "<html>\n";
echo "<title>Main Menu</title>\n";
echo "<LINK href=\"index.css\" rel=\"stylesheet\" type=\"text/css\">\n";
echo "<head>\n";
echo "<body>\n";
echo "<table width=100%>\n";
echo "<tr>\n";
echo "<th colspan=2>Main Menu</th>\n";
echo "</tr>\n";
echo "<tr>\n";
$sql = "SELECT * FROM INVENTORY WHERE usednew = \"used\"";
$sqla = "SELECT * FROM INVENTORY WHERE usednew = \"new\"";
$res = mysqli_query($mysqli,$sql);
$resa = mysqli_query($mysqli,$sqla);
if ($res) {
echo "<td class=\"description\">\n";
echo "<table width=100%>\n";
echo "<tr>\n";
echo "<th>";
echo "Used Items</th>\n";
echo "</tr>\n";
while ($menu = mysqli_fetch_array($res, MYSQLI_ASSOC)) {
echo "<tr>\n";
echo "<td class=\"menuitem\">";
echo "<a href=\"./submenu.php?category=";
echo $menu['usednew'];
echo "&type=";
echo $menu['type'];
echo "\">";
echo $menu['type'];
echo "</a>\n";
echo "</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
echo "<td class=\"description\">\n";
echo "<table width=100%>\n";
echo "<tr>\n";
echo "<th colspan=2>New Items</th>\n";
echo "</tr>\n";
while ($menua = mysqli_fetch_array($resa, MYSQLI_ASSOC)) {
echo "<tr>\n";
echo "<td class=\"menuitem\">";
echo "<a href=\"./submenu.php?category=";
echo $menua['usednew'];
echo "&type=";
echo $menua['type'];
echo "\">";
echo $menua['type'];
echo "</a>\n";
echo "</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
echo "</td>\n";
}
echo "</tr>\n";
echo "<tr>\n";
echo "<th colspan=2><a href=./add.php>Add An Item</a></th>";
echo "</tr>\n";
echo "</table>\n";
echo "</body>\n";
echo "</html>\n";
}
?>