I am working on the menu page of a restaurant website. The structure was like this:
[LIST]
[*]Soup
[*]Appetizers
[LIST]
[*][*]Salads
[*][*]Hot Appetizers
[/LIST]
[*]Main Courses
[LIST]
[*][*]Fish
[*][*]Meat
[*][*]Poultry
[/LIST]
[*]Side Dishes
[*]Menus
[/LIST]
and a link would look like this:
<a href="modules/site/menu.php?category_id=1&group_id=1">Soup</a>
As you can see from the anchor were the results based on two id’s category_id and group_id. Clicking the link soup would result in a listing of the soups they serve, and obviously the same for the other links like salads, meat, fish, menus etc. To achieve that I used the following query and output on the result page:
<?php
$category_id = filter_input(INPUT_GET, 'category_id', FILTER_SANITIZE_NUMBER_INT);
$group_id = filter_input(INPUT_GET, 'group_id', FILTER_SANITIZE_NUMBER_INT);
$qryMenu = "SELECT MG.menu_group_id, MG.menu_group, MI.menu_item, MI.description_dut, MI.description_eng, MI.description_dut2, MI.description_eng2, MI.description_dut3, MI.description_eng3, MI.description, MI.price
FROM menu_groups MG
INNER JOIN menu_items MI
ON MG.menu_group_id = MI.menu_group_id
WHERE menu_category_id = $category_id
AND MG.menu_group_id = $group_id";
if ($result = $mysqli->query($qryMenu)) {
while ($row = $result->fetch_assoc()) {
echo "<h1>{$row['menu_group']}</h1>
<dl>
<dt>{$row['menu_item']}<span>";if ($row['price'] == "Dagprijs"){}else{echo"€";}echo" {$row['price']}</span></dt>
</dl>";
}
}
?>
But suddenly the owner of the website would like to show the different 4 and 5 course dinners not longer as a listing but as separate items just like salads and Hot Appetizers under Appetizers and Fish, Meat and Poultry under Main Courses. Changing the database is/was not an option so I thought that including the id of each menu_item could do the trick so I changed the structure in the menu
[LIST]
[*]Menus
[LIST]
[*][*]Menu Canton
[*][*]Menu Szechuan
[*][*]Pekingeend Szechuan
[*][*]etc
[/LIST]
[/LIST]
and in the anchor I added menu_id
<li><a href="modules/site/menu.php?category_id=4&group_id=9[B]&menu_id=79[/B]">Menu Canton</a></li>
and added the following to the result page:
$menu_id = filter_input(INPUT_GET, 'menu_id', FILTER_SANITIZE_NUMBER_INT);
if ($menu_id ) {
$qryMenu .= "AND menu_item_id = $menu_id";
}
but that isn’t working at all as you can see here when you click on one of the first four menus under menus (Theater Menu is coming from a different group). What should I adjust to make it work?
Thank you in advance!