} } </script> </head> <body> <div id="container"> <?php include "db.php"; echo "<h2>Food Catalog</h2>"; //Search/categorizing sortBy(); //Just displaying the add new food and category buttons. addItem(); echo "<hr />"; //Querying the database and displaying. getFoodItems(); $id = NULL; $action = NULL; if (isset($_GET['id'])) { $id = $_GET['id']; } if (isset($_GET['action'])) { $action = $_GET['action']; } //If someone pressed delete and the url is set. if ($id && $action == "delete") { delete($id); } function sortBy() { $sort_by = "";
if (isset($_GET['page'])) { $page = $_GET['page']; } else { $page = 0; } $offset = $page * $page_break_limit; echo "<h2>Food Catalog</h2>"; echo "<h4>Click images to get more details.</h4>"; echo "<form action='Food_inventory_user.php?page=1' METHOD='POST'>"; echo "<input type='submit' value='Show Pages' />"; echo "</form>"; //Search/categorizing sortBy(); echo "<hr />"; //Querying the database and displaying. getFoodItems($page, $page_break_limit, $offset); function sortBy() { $sort_by = ""; //This variable will hold category types and other various methods of sorting. if (isset($_GET['sort_by'])) { $sort_by = $_GET['sort_by']; } //Query to get all unique category types to populate our drop-down list. $sql = "SELECT DISTINCT category_description, category_id FROM category ORDER BY category_description"; $result = mysql_query($sql); echo "<div id='sort'>\n\t\t\t\t\t\t\t<table style = 'text-align: center'>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<form action='Food_inventory_user.php' method='POST'>\n\t\t\t\t\t\t\t\t\t\t<td>Food name: <input type='text' name='search' id='search' /></td>\n\t\t\t\t\t\t\t\t\t\t<td>Food type: <select name='category_description'>\n\t\t\t\t\t\t\t\t\t\t\t<option selected=selected>--</option>"; while ($row = mysql_fetch_array($result)) { echo "<option value = '" . $row['category_id'] . "'>" . $row['category_description'] . "</option>"; } echo "</select></td>\n\t\t\t\t\t\t\t\t\t\t<td><input type='submit' name='search_button' value='Search' /></td>\n\t\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t\t<form action='Food_inventory_user.php' method='post'>\n\t\t\t\t\t\t\t\t\t\t\t\t<input type='submit' value='Show all food' />\n\t\t\t\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t </div>";