menu generation problem

hopper

Member
Messages
225
Reaction score
0
Points
16
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)?
PHP:
<?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";
}
?>
Edit:
nvm
i figured it out
changed
Code:
$sql = "SELECT * FROM INVENTORY WHERE usednew = \"used\"";
$sqla = "SELECT * FROM INVENTORY WHERE usednew = \"new\"";
to
Code:
$sql = "SELECT DISTINCT usednew,type FROM INVENTORY WHERE usednew = \"used\"";
$sqla = "SELECT DISTINCT usednew,type FROM INVENTORY WHERE usednew = \"new\"";
 
Last edited:

master257

New Member
Messages
33
Reaction score
0
Points
0
might just be an error with teh system... i would review ur files and see if everything is in order =]
 
Top