I previously posted the topic "Passing multiple variables with url php?" and have the solution requested.
meals_correction.php code snippet:
Code: Select all
<?php
for ($i=0; $i<$num_result; $i++)
{
$row = mysqli_fetch_row($result);
$url='meals_delete.php?id='.$row[0].'&ordertime='.$row[11];
?>
<tr>
<td><span class="style1"><?php echo $row[2];?></span></td> <td><span class="style1"><?php echo $row[4];?></span></td> <td><span class="style1"><?php echo $row[5];?></span></td> <td><center>
<span class="style1"><?php echo '<a href='.$url.'>'. $row[0].'</a>';?></span></td>
Code: Select all
<?php
$id=$_GET['id'];
$ordertime=$_GET['ordertime'];
echo $ordertime;
@ $db = new mysqli('…..');
if (mysqli_connect_errno())
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
$result = $db->query("DELETE FROM meals_entry WHERE ordertime = $ordertime ");
$db->close();
header("location:meals_entry.php");
?>
If I change the query WHERE to id = $id the code works, but from the previous post, the id is member-assigned, and a member could order more than one meal. Using id in the delete statement deletes all rows with the id, and LIMIT gets the first row encountered, not necessarily the meal to be deleted.
The echo $ordertime; statement was followed with exit; just to make certain that the ordertime variable was indeed passed, and it was.
The table meals_entry field ordertime is the last in the table and was set as time, but I have since set it to varchar just to see if that made a difference, but it does not.
Any ideas as to what is going on and how to resole the problem?
Thanks again for your help.
Cheers.