Passing multiple variables with url php?
Posted: Fri Aug 02, 2013 9:04 pm
Hello,
I maintain an online database of members and meals for a non-profit seniors centre. We just switched from using a spreadsheet on a laptop to online entry on August 1st., and some problems are coming up.
Members order a meal which is added to the database of meals ordered; sometimes a member orders multiple meals to have a meal for the weekend, holidays and so on.
The data captured in the meals_entry table includes id, date, quantity of meals, meal, and how paid.
It has occurred that after placing an order, the member decides to change the meal ordered. The code below works well, but if a member orders two meals, the code deletes all meals for that day with the member id (row 0) rather than the particular meal that should be changed.
My question is how do I change the $url='meals_delete.php?id='.($row[0]); statement to include the meal ordered (row 5)?
I am using the following code to display all the meals ordered on a particular day so that the appropriate meal can be cancelled and a replacement ordered.
I use the following code on the meals_delete.php page but cannot find a way to pass the meal variable.
$id=$_GET['id'];
$meal=$_GET['meal'];
Thanks in advance for your comments and help.
Cheers!
I maintain an online database of members and meals for a non-profit seniors centre. We just switched from using a spreadsheet on a laptop to online entry on August 1st., and some problems are coming up.
Members order a meal which is added to the database of meals ordered; sometimes a member orders multiple meals to have a meal for the weekend, holidays and so on.
The data captured in the meals_entry table includes id, date, quantity of meals, meal, and how paid.
It has occurred that after placing an order, the member decides to change the meal ordered. The code below works well, but if a member orders two meals, the code deletes all meals for that day with the member id (row 0) rather than the particular meal that should be changed.
My question is how do I change the $url='meals_delete.php?id='.($row[0]); statement to include the meal ordered (row 5)?
I am using the following code to display all the meals ordered on a particular day so that the appropriate meal can be cancelled and a replacement ordered.
Code: Select all
$query = ("SELECT * FROM meals_entry WHERE date = curdate() order by name asc");
$result = $conn->query($query);
$num_result = 0;
$num_result = $result->num_rows;
…
<table border="5">
<tr>
<th><span class="style1">Name</span></th><th><span class="style1">Qty</span></th><th><span class="style1">Meal</span></th><th><span class="style1"> ID</span></th>
<?php
for ($i=0; $i<$num_result; $i++)
{
$row = mysqli_fetch_row($result);
$url='meals_delete.php?id='.($row[0]);
?>
<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>
<?php
} ?>
</tr>
<tr style="style1">
Click on ID number to delete the meal you wish to change,<br>
or <a href="meals_entry.php">click here to return to the Meals Entry page.</a><p>
</tr>
</table>
$id=$_GET['id'];
$meal=$_GET['meal'];
Thanks in advance for your comments and help.
Cheers!