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

<?php
/***************************************************************************
 *			del_scat.php	                                   *
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~	                   *
 *   File Info:		  Delete category                                  *
 *   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> Deleting record from CATEGORY table</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
        $catid = addslashes($_POST["catid"]);
        $act = addslashes($_POST["act"]);
	$done = addslashes($_POST["done"]);
	
}

if ($act == "delete")
{
$table = "category";
$done = "FALSE";
$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.");
$sql1 = " SELECT * from $table order by catid";
$rs = mysql_query($sql1,$conn)
	or die("Could not execute SQL query!!! Possibly SQL query already been executed.");
while($row = mysql_fetch_array($rs))
{
	$done = "OK";
}
$sql = "DELETE from $table where catid = $catid";
$rs = mysql_query($sql,$conn)
	or die("Unable to delete category record from category table with category id = $catid");
if ($done == "OK")
echo "<br><center><img src=images/bullets.gif border=0><font face=verdana size=2> Category record id  '$catid' successfully deleted from category table</font></center>";
if ($done == "FALSE")
echo "<br><center><img src=images/bullets.gif border=0><font face=verdana size=2> Category record id  '$catid' not deleted from category table</font></center>";
}
else
{
$done = "FALSE";
$table = "category";
$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.");
$sql = " SELECT * from $table order by catid";
$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>Category ID</font></th>";
$list.="<th><font face=verdana size=2>Category</font></th>";
$list.="<th><font face=verdana size=2>Picture</font></th></tr>";

while($row = mysql_fetch_array($rs))
{
	$list.= "<tr><font face=verdana size=2>";
	$list.="<td>".$row["catid"]."</td>";
	$list.="<td>".$row["category"]."</td>";
	$list.="<td>".$row["cpic"]."</td>";
	$list.="</font></tr>";
	$done = "OK";
}
$list.= "</table>";
echo($list);
echo "
<br><form action = del_scat.php method = post>
<input type = hidden name = act value =delete>
<font face=verdana size=2 color=navy>Delete Category ID:</font><br>
<input type = text name = catid>
<input type = submit value = 'Delete Category'></form>";
}
echo "<br><br><img src=images/line.gif border=0 width=100% height=1>";
include("./your-footer.inc")
?>

</BODY>
</HTML>