<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Delete a Record</TITLE>
</HEAD>
<BODY>

<?
/***************************************************************************
 *			do_deleterec4a.php	          *
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~	          *
 *   File Info:		  Delete Orders record                    *
 *   Copyright:       Copyright 2003 http://www.128concepts.com  *
 *						          *
 ***************************************************************************/
include("./config.php");
include("./header.inc");
?>
<?
$table = "myorders";
  if ($_SERVER['REQUEST_METHOD'] == "POST") 
  {
        # escape data and set variables
        $user_id = addslashes($_POST["user_id"]);
}

$conn = @mysql_connect($server,$user,$password)
	or die("Unable to connect to SQL database...");
$rs = @mysql_select_db($database,$conn) 
	or die("Unable to select the database 'mydata'...Please press 'Create Database' to create new database.");
echo("<br>Deleting user record with User ID = ");
echo($user_id);
echo("<br>");
$done = "FALSE";
$sql = "SELECT * from $table where user_id = '$user_id'";
echo("$sql <br><hr><br>");
$rs = @mysql_query($sql,$conn)
	or die("Could not execute SQL query!!! Possibly SQL query already been executed.");
while($row=mysql_fetch_array($rs))
{
       echo("User ID: ".$row["user_id"]); 
       echo(" <br>Item".$row["sel_item"]);
       echo(" <br>Description: ".$row["sel_item_title"]);
       echo(" <br>Quantity: ".$row["sel_item_qty"]);
       echo(" <br>Price:  ".$row["sel_item_price"]);
       echo(" <br>Total Price: ".$row["sel_item_totalprice"]);
      echo(" <br>Date Added: ".$row["date_added"]."<br>");
       echo("Press the 'View Records' menu link to view all orders records.<hr>");
       $done = "OK";
}
if ($done=="FALSE")
{
	echo("<center>Opps...its seems cannot delete user record with USER ID = ");
	echo("$user_id</center>");
}
$sql = " DELETE FROM $table WHERE user_id= '$user_id'";
?>
<h3><center>Deleting a Record from MYORDERS</center></h3>
<?

$sql_result = mysql_query($sql,$conn)
	or die("Couldn't delete record.");
if ($sql_result)
	echo("<center><strong>Deleting of orders record successful</center></strong>");
else
	echo("<center><strong><font color = $highlight>Deleting of orders record not successful</font></center></strong>");
?>
<br><table width="100%"><tr align="left" class="subtitle"><td>[<a href="./create_db.php">Create database</a> | <a href="./delete_db.php">Delete database</a> | <a href="./create_menu.php">Create table</a>  | <a href="./add_menu.php">Add Record </a>  | <a href="./view_menu.php">View Records</a>  | <a href="./del_menu.php">Delete Record</a> | <a href="./upd_menu.php">Update Record</a> | <a href="./index.php">Home</a>  </a>]</td></tr></table><hr>
<?php include("./your-footer.inc");?>
</BODY>
</HTML>
