我正在开发一个在线菜单订购系统,我想根据其类别过滤数据。我试图让它与这段代码一起工作,但它只显示一个类别。
**<li><?php echo "<a href='clubmarumenu.php?choice=".$category."'>"?> Scotch/Bourbon</a></li>
<li><?php echo "<a href='clubmarumenu.php?choice=".$category."'>"?> Brandy/Cognac</a></li>
<li><?php echo "<a href='clubmarumenu.php?choice=".$category."'>"?> Vodka/Gin/Tequila/Apertifs/Liqueur</a></li><br>
<li><?php echo "<a href='clubmarumenu.php?choice=".$category."'>"?> Beer/Softdrinks</a></li>
<li><?php echo "<a href='clubmarumenu.php?choice=".$category."'>"?> Cocktails</a></li>**
^ 基本上这些是类别,下面是如何显示它们。**
<?php
$category = $_GET['choice'];
$category = str_replace('%', ' ', $category);
$query = "SELECT * FROM product_drinks WHERE drinks_cat = '" . $category . "'";
$result = mysql_query($query);
$total_records = mysql_num_rows($result); // the number of records in your result set
$num_cols = 2; // the number of columns
$num_rows = ceil($total_records / $num_cols); // the number of rows
$num = 0; // don't change this value, this is the first number of each record inside a record set
echo "<table style= 'cellpadding:8 width:100'>\n";
// next the loop for the table rows
for ($rows = 0; $rows < $num_rows; $rows++) {
echo "<tr bgcolor='black'>\n";
// this is the loop for the table columns
for ($cols = 0; $cols < $num_cols; $cols++) {
if ($num < $total_records) { // show records if available (reduce by one because the first record is no. "0" (zero)
// first create variables with the values of the current record
$title = mysql_result($result, $num, "drinks_name");
$clean_name = str_replace('_', ' ', $title);
$price = mysql_result($result, $num, "drinks_shot");
$price2 = mysql_result($result, $num, "drinks_bottle");
$category = mysql_result($result, $num, "drinks_cat");
$description = mysql_result($result, $num, "drinks_image");
$title = str_replace(' ', '%', $title);
echo "<td class='label'><a class='fancybox fancybox.ajax' href='food.php?drink=" . $title . "'>
<img src='" . mysql_result($result, $num, 'drinks_image') . "' class='masterTooltip' title= '" . $category . "'</a><br>";
echo "<td style='width:50%' class='desc'><b>" . $clean_name . "</b><br> Shot:<font style='color:#0072bc'> Php " . $price . "</font><br> Bottle: <font style='color:#724c0e'>Php " . $price2 . "</font></td>\n";
} else { // show an empty cell
echo "<td> </td>\n";
}
$num++; // raise the number by one for the next record
}
echo "</tr>\n"; // there are no more cols in this row, close the table row tag
}
echo "</table>\n"; // end of the region = closing tag for the table element
?>
**
我希望我能翻过这堵墙。请帮忙~