Hi,
I have created a mysql database containing menu dishes for a restaurant.
The idea is to store all dishes on the database whether the dish is being sold or has been sold in the past. Each dish (database row) has a simple indicator (yes/no) to determine if the row should be displayed for the current menu.
My issue is that when the chef wants to change the menu they will have to change the indicator on the stored row from off to on and vice versa.
To help with this I have built a simple query and form to present the data to the chef, however the form is mainly constructed of PHP variables resulting from the query.
i.e.
$query = "SELECT * FROM menu";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
$id = $row['id'];
$type = $row['type'];
$item = $row['item'];
$description = $row['description'];
$price = $row['price'];
$addmenu = $row['addmenu'];
$string = 'yes';
if (strstr($addmenu,$string)) {
echo "<tr><td>".$id."</td><td>".$type."</td><td>".$item."</td><td>".$description."</td><td>".$price."</td><td><input type=checkbox checked=checked name=".$id."</td></tr>";
}
else
{
echo "<tr><td>".$id."</td><td>".$type."</td><td>".$item."</td><td>".$description."</td><td>".$price."</td><td><input type=checkbox name=".$id."</td></tr>";
}}
This outputs a nice display showing the status of each database row.
my intention is for the chef to change the value of the checkboxes and repost the form so I can update the database with some very simple sql.
However, as each checkbox name is a php variable, I do not know how to pass the real value to process.
Also, I cannot predetermine the checkbox name as the user can add new rows to the database as chef creates new dishes.
Lastly, if it is possible to pass the php variable as a value for processing, i'm guessing I will have to create some sort of loop to identify each instance of of the variable/value.
Thanks for your time.