[SOLVED] 'Remove' section not removing until clicked a secon
Posted: Tue Aug 24, 2004 8:43 pm
I have listed code below. The problem I'm having is with the 'remove' section. When I try to remove an order, the order still appears on the page until I click on 'remove' a second time.
Any suggestions?
Any suggestions?
Code: Select all
<?php
ob_start();
session_start();
$authorizedUsers = "visitor,admin";
$donotCheckaccess = "false";
$_SESSION['prevUrl']="orders.php";
if (isset($_SESSION['frm_username']))
{
showPage();
}
else
{
header("Location:login.php");
}
switch(@$_GET["action"])
{
case "remove_orders":
{
RemoveOrder($_GET["orderID"]);
}
}
function RemoveOrder($orderID)
{
// Uses an SQL delete statement to remove an item from
// the users cart
include ('connection/db.php');
mysql_query("DELETE FROM orders WHERE orderID = $orderID");
showPage();
}
function showPage()
{
error_reporting (E_ALL);
function showOrders()
{
include ('connection/db.php');
$orderQuery="SELECT * FROM orders WHERE userID='" . $_SESSION['userID'] . "'";
//Retrieve the item details of the cart
$result = mysql_query ($orderQuery) or die("ERROR, ERROR!".mysql_error());
$numRows = mysql_num_rows ($result);
if ($numRows == 0)
{
echo "<h4><align =",center,">You do not have any open orders at present.</h4><br />";
}
else
{
echo "
<table align=",center,">
<tr>
<td><h1>Your Shopping Cart</h1>
</td>
</tr>
<tr>
<td><h4>Order ID</h4></td>
<td><h4>Date Submitted</h4></td>
<td><h4>Date Shipped</h4></td>
<td><h4>Total Value of Order</h4></td>
<td><h4>Remove?</h4></td>
</tr>";
//Go through each of the items in the cart
while ($row=@mysql_fetch_array($result))
{
//Show the details of the item
echo "\n\t<td><h3>";
echo $row["orderID"];
echo "</h3></td>";
//Show the details of the item
echo "\n\t<td><h3>";
echo $row["dateSubmitted"];
echo "</h3></td>";
//Show the details of the item
echo "\n\t<td><h3>";
echo $row["dateShipped"];
echo "</h3></td>";
//Show the details of the item
echo "\n\t<td><h3>";
echo $row["total"];
echo "</h3></td>";
//Link to remove item - blank for now
echo "\n\t<td>";
echo "<a href=orders.php?action=remove_orders&orderID=",$row["orderID"],">Remove</a>";
echo "</td>";
echo "\n</tr>";
}
}
}
?>