<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Viewing / Deleting Records</TITLE>
</HEAD>
<BODY>

<?php
/***************************************************************************
 *			del_shiporder.php	                           *
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~	                   *
 *   File Info:		  Delete Shipping Order                            *
 *   Copyright:       Copyright 2003 http://www.128concepts.com            *
 *						                           *
 ***************************************************************************/
include ("./header.inc");
?>
<img src=images/line.gif border=0 width=100% height=1><br><br>
<center><img src=images/computer.gif border=0><font face=verdana size=3 color=darkred> Viewing Records from SHIPPING table / Delete Records</font></center><br>
<center>
<table width="500" border=1><tr align="justify" class="subtitle"><td>
  <p align="center">
  <img border="0" src="images/database.GIF" width="24" height="24"><font face=Verdana size=1><a href="./create_db.php">Create database</a>&nbsp;
  <img border="0" src="images/database.GIF" width="24" height="24"></font><a href="./delete_db.php"><font face=Verdana size=1>Delete database</font></a><font face="Verdana" size="1">&nbsp;
  <img border="0" src="images/Records.GIF" width="24" height="24"><a href="./create_menu.php">Create table</a>&nbsp;&nbsp;&nbsp;&nbsp;
  <img border="0" src="images/Records.GIF" width="24" height="24">&nbsp;
  </font> <a href="./add_menu.php"><font face=Verdana size=1>Add Record </font></a>  
  </p>
  <p align="center">&nbsp;<font face="Verdana" size="1"><img border="0" src="images/Records.GIF" width="24" height="24"></font><a href="./view_menu.php"><font face=verdana size=1>View Records</font></a>&nbsp;
  <font face="Verdana" size="1">&nbsp;&nbsp;&nbsp;
  <img border="0" src="images/Records.GIF" width="24" height="24"></font><a href="./del_menu.php"><font face=verdana size=1>Delete Record</font></a>
  <font face="Verdana" size="1">&nbsp;&nbsp;&nbsp;
  <img border="0" src="images/Records.GIF" width="24" height="24"></font> <a href="./upd_menu.php"><font face=verdana size=1>Update Record</font></a>&nbsp;
  <img border="0" src="images/home-to.GIF" width="24" height="24"><font face=verdana size=1>&nbsp; <a href="./index.php">Home</a></font>  </a></td></tr></table><br></center>
<?php
include("./config.php");
 if ($_SERVER['REQUEST_METHOD'] == "POST") 
{
        # escape data and set variables
        $act = addslashes($_POST["act"]);
        $orderid = addslashes($_POST["orderid"]);
}
$table = "shipping";
$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...Please press 'Create Database' to create new database.");

# delete records  #

if ($act == "delete")
{
echo("Deleting user record with User ID = ");
echo($orderid);
echo("<br>");
$sql = "SELECT * from $table where orderid = '$orderid'";
echo("$sql <br><img src=images/line.gif border=0 width=100% height=1><br>");
$rs = @mysql_query($sql,$conn)
	or die("Could not execute SQL query!!! Possibly SQL query already been executed.");
$done = "FALSE";
while($row=mysql_fetch_array($rs))
{
       echo("<font face=verdana size=2>Order ID: </font>".$row["orderid"]); 
       echo(" <br><font face=verdana size=2>Status</font>".$row["status"]);
       echo(" <br><font face=verdana size=2>Shipping Info.</font>: ".$row["shipinfo"]);
       echo(" <br><font face=verdana size=2>Date: </font>".$row["datetime"]);
       echo(" <br><font face=verdana size=2>Ship. Type:  </font>".$row["shiptype"]);
       echo(" <br><font face=verdana size=2>Ship. Location: </font>".$row["shiploct"]);
      echo(" <br><font face=verdana size=2>Order Stat: </font>".$row["orderstat"]."<br>");
       echo("<br><font face=verdana size=2>Press the 'View Records' menu link to view all shipping records.</font><img src=images/line.gif border=0 width=100% height=1");
       $done = "OK";
}
if ($done=="FALSE")
{
	echo("<br><br><center><img src=images/bullets.gif border=0><font face=verdana size=2>Opps...its seems cannot delete user record with USER ID = ");
	echo("$orderid</font></center>");
	include_once("./your-footer.inc");
	exit();
}
$sql = " DELETE FROM $table WHERE orderid= '$orderid'";
?>
<center><img src=images/bullets.gif border=0><font face=verdana size=2>  Deleting a Record from SHIPPING</font></center>
<?

$dones = "FALSE";
$sql1 = " SELECT * from $table where orderid='$orderid'";
$rs = mysql_query($sql1,$conn)
	or die("Could not execute SQL query!!! Possibly SQL query already been executed.");
while($row = mysql_fetch_array($rs))
{
	$dones = "OK";
}

$sql_result = mysql_query($sql,$conn)
	or die("Couldn't delete record.");

if ($dones == "OK")
echo("<br><br><center><font face=verdana size=2 color=navy>Deleting of shipping record successful</font></center>");
}
# display records #

if ($act == NULL)
{
$sql = " SELECT * from $table";
$rs = mysql_query($sql,$conn)
	or die("Could not execute SQL query!!! Possibly SQL query already been executed.");
$list = "<table border =\"1\" cellpadding =\"2\" align=center>";
$list.="<tr ><th><font face=verdana size=2>Order ID</font></th>";
$list.="<th><font face=verdana size=2>Status</font></th>";
$list.="<th><font face=verdana size=2>Ship.Info</font></th>";
$list.="<th><font face=verdana size=2>Date</font></th>";
$list.="<th><font face=verdana size=2>Ship.Type</font></th>";
$list.="<th><font face=verdana size=2>Location</font></th>";
$list.="<th><font face=verdana size=2>Order Status</font></th></tr>";

while($row = mysql_fetch_array($rs))
{
	$list.= "<tr><font face=verdana size=2>";
	$list.="<td>".$row["orderid"]."</td>";
	$list.="<td>".$row["status"]."</td>";
	$list.="<td>".$row["shipinfo"]."</td>";
	$list.="<td>".$row["datetime"]."</td>";
	$list.="<td>".$row["shiptype"]."</td>";
	$list.="<td>".$row["shiploct"]."</td>";
	$list.="<td>".$row["orderstat"]."</td>";
	$list.="</font></tr>";
}
$list.= "</table>";
echo($list);

echo "<br><img src=images/line.gif border=0 width=100% height=1>
<font face=verdana size=2>Delete Record from SHIPPING</font>
<form action =del_shiporder.php method =POST>
<font face=verdana size=2>Order ID: </font><input type =text name =orderid>
<input type = hidden name = act value ='delete'>
<input type =submit value='Delete Record'>
</form><br> "; 
}

?>

<?php include("./your-footer.inc");?>
</BODY>
</HTML>