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

<?
/***************************************************************************
 *			do_updates2.php	                                   *
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~	                   *
 *   File Info:		  Update stocks record                             *
 *   Copyright:       Copyright 2003 http://www.128concepts.com            *
 *						                           *
 ***************************************************************************/
include("./config.php");
include("./header.inc");
?>
<?

$table = "stocks";
  if ($_SERVER['REQUEST_METHOD'] == "POST") 
  {
        # escape data and set variables
        $pid = addslashes($_POST["pid"]);
        $sitem = addslashes($_POST["sitem"]);
        $scat = addslashes($_POST["scat"]);
        $spic = $_POST["spic"];
        $stock = addslashes($_POST["stock"]);
        $color = addslashes($_POST["color"]);
        $size = addslashes($_POST["size"]);
}
$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.");
echo("<br><img src=images/line.gif border=0 width=100% height=1><font face=verdana size=2>Updating stocks record with Stock ID = ");
echo($pid);
echo("</font><br>");
$done = "FALSE";
$sql = " SELECT pid,sitem,scat,spic,stock,color,size from $table where pid = $pid";
$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("<font face=verdana size=2>Stock ID: </font>".$row["pid"]); 
       echo(" <br><font face=verdana size=2>Stock Item: </font>".$row["sitem"]);
       echo(" <br><font face=verdana size=2>Category: </font>".$row["scat"]);
       echo(" <br><font face=verdana size=2>Picture: </font>".$row["spic"]);
       echo(" <br><font face=verdana size=2>Stock: </font>".$row["stock"]);
       echo(" <br><font face=verdana size=2>Color: </font>".$row["color"]);
       echo(" <br><font face=verdana size=2>Size: </font>".$row["size"]."<br>");
       echo("<font face=verdana size=2>Press the 'View Records' menu link to view all stocks records.</font><img src=images/line.gif border=0 width=100% height=1>");
       $done = "OK";
}
if ($done=="FALSE")
{
	echo("<br><center><img src=images/bullets.gif border=0><font face=verdana size=2> Opps...its seems cannot update stocks record with STOCK ID = ");
	echo($pid);
	echo "</font>";
	include_once("./your-footer.inc");
	exit();
}
?>
<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>Updating a Record to STOCKS</font></center><br>
<?

echo("<font face=verdana size=2>Updating stock item</font><br>");
$sql="UPDATE $table set sitem=";
$sql.="'$sitem'";
$sql.=" where pid = $pid";
$sql_result = mysql_query($sql,$conn)
	or die("Couldn't update record.");
echo("<font face=verdana size=2>Updating category</font><br>");
$sql="UPDATE $table set scat=";
$sql.="'$scat'";
$sql.= " where pid = $pid";
$sql_result = mysql_query($sql,$conn)
	or die("Couldn't update record.");
echo("<font face=verdana size=2>Updating picture</font><br>");
$sql="UPDATE $table set spic='$spic'";
$sql.=" where pid = $pid";
$sql_result = mysql_query($sql,$conn)
	or die("Couldn't update record.");
echo("<font face=verdana size=2>Updating stock</font><br>");
$sql="UPDATE $table set stock=$stock";
$sql.=" where pid = $pid";
$sql_result = mysql_query($sql,$conn)
	or die("Couldn't update record.");
echo("<font face=verdana size=2>Updating color</font><br>");
$sql="UPDATE $table set color='$color'";
$sql.=" where pid = $pid";
$sql_result = mysql_query($sql,$conn)
	or die("Couldn't update record.");
echo("<font face=verdana size=2>Updating size</font><br>");
$sql="UPDATE $table set size='$size'";
$sql.=" where pid = $pid";
$sql_result = mysql_query($sql,$conn)
	or die("Couldn't update record.");
?>
<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("./your-footer.inc");?>
</BODY>
</HTML>
