HI there,
I am trying to group my results in PHP by Menu_Type like this
Menu_Type Menu_Description Menu_Price
breakfast
Bacon & Eggs £2.50
Toast £3.50
Lunch
Salad £3.00
Sandwich £3.50
Mains
Starvation £free o😉 only kidding
etc
I tried to apply the code from searching the forums here -
http://phpbuilder.com/board/showthread.php?t=10325181&highlight=grouping
However could not get it to work like this, my query is built like this
mysql_select_db($database_Bar163, $Bar163);
$query_MenuVariables = "SELECT menu_tbl.MenuID, menu_tbl.Bar163_LocationID, menu_tbl.Menu_Order, menu_tbl.Menu_Type, menu_tbl.Menu_Description, menu_tbl.Price FROM menu_tbl WHERE (((Menu_tbl.Bar163_LocationID) LIKE '$menuURL')) ORDER BY menu_tbl.Menu_Order";
$MenuVariables = mysql_query($query_MenuVariables, $Bar163) or die(mysql_error());
$row_MenuVariables = mysql_fetch_assoc($MenuVariables);
$totalRows_MenuVariables = mysql_num_rows($MenuVariables);
My results echo'd into the page look like this: (I thought that perhaps two loops would work, one inside the other, but it only groups the first Menu_Type and then all the records.
<tr>
<td id="menu_header3"><?php echo $row_MenuVariables['Bar163_LocationID']; ?></td>
<td></td>
<td></td>
</tr>
<?php do { ?>
<tr id="menu_table">
<td align="left"><?php echo $row_MenuVariables['Menu_Type'];?></td>
</tr>
<?php do { ?>
<tr>
<td></td>
<td align="left" colspan="2"><?php echo $row_MenuVariables['Menu_Description']; ?></td>
<!--<td align="left"></td>-->
<td align="left">£<?php echo $row_MenuVariables['Price']; ?></td>
</tr>
<?php } while ($row_MenuVariables = mysql_fetch_assoc($MenuVariables)); ?>
<tr>
<td colspan="3"><br /> </td>
</tr>
<?php } while ($row_MenuVariables = mysql_fetch_assoc($MenuVariables)); ?>
The question is how can I get it to return all the results and return the menu_type only once.
Any help much appreciated.
THanks
Andi