Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/istore/
Upload File :
Current File : /var/www/html/mmishra/istore/stcategory.inc

<h3>Item Category</h3>
<center>

<?php
$tbl = "st_category";

$id = $_REQUEST["id"];
$code = $_POST["code"];
$description = $_POST["description"];
$dated = date("Y-m-d");

if ($_POST["submit"] == 'SAVE') {
	if (mysql_num_rows(mysql_query("select * from $tbl where id=$id"))) {
		mysql_query("update $tbl set code='$code',description='$description',loginID='$user' 
		where id=$id");
	} else {
        mysql_query("insert into $tbl(code,description,loginID) 
		values('$code','$description','$user')");
	}
} else if ($_POST["submit"] == 'DELETE') {
	mysql_query("delete from $tbl where id=$id");
}

?>

<table width='80%' border='1' style='border-collapse: collapse'>
<tr><th>No</th><th>Code</th><th>Description</th><th nowrap>Dated</th></tr>

<?php
echo "<tr><td><a name='new'>+</a></td>";
if (!$id) {
        echo "<td><input type='text' name='code' size='30' value=''></td>
        <td><input type='text' name='description' size='50' value=''></td>
        <td nowrap>$dated<input type='hidden' name='id' value='0'></td></tr>
        <tr><th colspan='4'><input type='submit' name='submit' value='SAVE'></th>";
} else {
        echo "<td colspan='4'><a href='?pg=$pg&id=#new'>Category</a></td>";
}
echo "</tr>";

//existing records
$rs = mysql_query("select * from $tbl order by id");
while ($o = mysql_fetch_object($rs)) {
	$i++;
	echo "<tr><td><a name='$i' href='?pg=$pg&id=$o->id#$i'>$i</a></td>";
	if ($o->id == $id) {
		echo "<td><input type='text' name='code' size='30' value='$o->code'></td>
		<td><input type='text' name='description' size='50' value='$o->description'></td>
		<td nowrap>$dated<input type='hidden' name='id' value='$o->id'></td></tr>
		<tr><th colspan='3'><input type='submit' name='submit' value='SAVE'></th>
		<th><input type='submit' name='submit' value='DELETE'></th>";
	} else {
		echo "<th>$o->code</th><td>$o->description</td><td>$o->dateCreation</td>";
	}
	echo "</tr>";

}
?>

</table>
</center>