This works fine, this produces ALL the orders
<?php require_once('Connections/Shop.php'); ?>
<?php
mysql_select_db($database_Shop, $Shop)
or die("Could not select the test database");
$query_rsorders = "SELECT orderid, username, total, order_status FROM orders";
$rsorders = mysql_query($query_rsorders, $Shop)
or die(mysql_error());
//$row_rsorders = mysql_fetch_assoc($rsorders);//This is done in the while, not needed here
//$totalRows_rsorders = mysql_num_rows($rsorders);//Unless you are just curious then this is not necessary
//echo "There are $totalRows_rsorders rows in the table<br />";//but if you want to know then uncomment these two lines
//mysql_free_result($rsorders);//not necessary
?>
<table border="1">
<tr>
<th>Order ID </th>
<th>Username</th>
<th>Total</th>
<th>Order Status </th>
<td> </td>
</tr>
<?php while ($row_rsorders = mysql_fetch_assoc($rsorders)){ ?>
<tr>
<td><?php echo $row_rsorders['orderid']; ?></td>
<td><?php echo $row_rsorders['username']; ?></td>
<td><?php echo $row_rsorders['total']; ?></td>
<td><?php echo $row_rsorders['order_status']; ?></td>
<td><a href="confirmDelete.php?recordID=<?php echo $row_rsorders['orderid']; ?>">Delete</a></td>
</tr>
<?php
}
?>
</table>
This is the confirmation page, it only produces one out put tho, i want to select the order from the orders page, and it should come up on this page, asking me if i am sure i want to delete it...BUT its not working
<?php require_once('Connections/Shop.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
if ((isset($_GET['orderid'])) && ($_GET['orderid'] != "")) {
$deleteSQL = sprintf("DELETE FROM orders WHERE orderid=%s",
GetSQLValueString($_GET['orderid'], "int"));
echo $deleteSQL;
mysql_select_db($database_Shop, $Shop);
$Result1 = mysql_query($deleteSQL, $Shop) or die(mysql_error());
$deleteGoTo = "index.html";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
echo $deleteGoTo;
header(sprintf("Location: %s", $deleteGoTo));
}
mysql_select_db($database_Shop, $Shop);
$query_Details = "SELECT orderid, total, order_date, order_status FROM orders";
$Details = mysql_query($query_Details, $Shop) or die(mysql_error());
$row_Details = mysql_fetch_assoc($Details);
$totalRows_Details = mysql_num_rows($Details);
echo $query_Details;
echo $Details;
echo $row_Details;
echo $totalRows_Details;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Confirm Delete</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<p>Please confirm you would like to delete this order?</p>
<p>
<label for="textfield">Order ID</label>
<input name="orderid" type="text" id="orderid" value="<?php echo $row_Details['orderid']; ?>" />
</p>
<p>
<label for="textfield">Total:</label>
<input name="total" type="text" id="total" value="<?php echo $row_Details['total']; ?>" />
</p>
<p>
<label for="textfield">Date:</label>
<input name="date" type="text" id="date" value="<?php echo $row_Details['order_date']; ?>" />
</p>
<p>
<label for="textfield">Status: </label>
<input name="status" type="text" id="status" value="<?php echo $row_Details['order_status']; ?>" />
</p>
<p>
<input name="Confirm Delete" type="submit" id="Confirm Delete" value="Confirm Delete" />
</p>
<p>
<input name="hiddenField" type="hidden" value="orderid" />
</p>
</form>
</body>
</html>
<?php
mysql_free_result($Details);
?>