This function populates a drop down menu with database field, when a choice from the menu is made and the Edit Menu button is pressed, another function is called elsewhere to dispaly the full results.
Now i have added a delete button but i cant for the life of me figure out how to delete the chosen menu, ive tried using if(isset($_POST['delete']) and then performing the delete but i just cant get it to work, can anyone help me. Also im trying to figure out a way of separating most of the php code into a different function but with no success.
This funtion is called from a file named menu_selection.php
<?php
display_menu_selection_form()
{
// create connection
$conn = db_connect();
if (!$conn)
return false;
// create SQL statement
$query = "SELECT *
FROM menu";
// execute SQL query and get result
$sql_result = mysql_query($query,$conn);
//check to see if there are results from the query
if (!$sql_result)
{
echo("<p>Error performing query: " . mysql_error() . "</p>");
}
$num=mysql_num_rows($sql_result);
if($num>0)
{
// format results by row into option list
while ($row = mysql_fetch_array($sql_result))
{
$menu = $row["menu_name"];
$option_block .= "<option value=\"$menu\">$menu</option>";
}
}
?>
<form method="post" action="menu_edit.php">
<table align="center" border="0">
<tr>
<td>
<select name="menu_name">
<?php echo "$option_block"; ?>
</select>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Edit Menu" name="submit">
<input type="submit" value="Delete Menu" name="delete">
</td>
</tr>
</table>
</form>
<?php
};
?>
thanks
NCC1701