Your IP : 216.73.216.40


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

<h3>Item Subcategory</h3>
<?php
$tbl = "st_subcategory";

$id = $_REQUEST["id"];
$code = $_POST["code"];
$description = $_POST["description"];
$category = $_REQUEST["category"];
$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',category=$category,dated=now() 
		where id=$id");
	} else {
                mysql_query("insert into $tbl(code,description,category,dated) 
		values('$code','$description',$category,now())");
	}
} else if ($_POST["submit"] == 'DELETE') {
	mysql_query("delete from $tbl where id=$id");
}

?>

<center>
<table width='100%'>
<tr><td width='25%'>
</td><th>

<?php

echo "Select category <select name='category' onchange=\"javascript: document.location.href='?pg=$pg&category='+this.value\">
<option value=''></option>";

$rs = mysql_query("select id,code from st_category order by code");
while ($o = mysql_fetch_object($rs)) {
        echo "<option value='$o->id'";
        if ($o->id == $category) echo " selected";
	echo ">$o->code</option>";
}

echo "</select>
</th><td width='25%' align='right'>
<font size='+1'>[ </font><a href='?pg=$pg&category=$category&refresh=1'>Refresh</a> <font size='+1'>]</font>
</td></tr>
</table>
";

if ($category) {
	echo "<table width='80%' border='1' style='border-collapse: collapse'>
	<tr><th>No</th><th>Code</th><th>Description</th><th>Dated</th></tr>";

	echo "<tr><td><a name='new'>New</a></td>";
	if (!$id) {
        	echo "<td><input type='text' name='code' size='50' value=''></td>
	        <td><input type='text' name='description' size='90' value=''></td>
        	<td>$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='3'><a href='?pg=$pg&category=$category&id=#new'>Subcategory</a></td>";
	}
	echo "</tr>";

	//existing records
	$rs = mysql_query("select * from $tbl where category=$category order by id");
	while ($o = mysql_fetch_object($rs)) {
		$i++;
		echo "<tr><td><a name='$i' href='?pg=$pg&category=$category&id=$o->id#$i'>$i</a></td>";
		if ($o->id == $id) {
			echo "<td><input type='text' name='code' size='50' value='$o->code'></td>
			<td><input type='text' name='description' size='90' value='$o->description'></td>
			<td>$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->dated</td>";
		}
		echo "</tr>";
	}
	echo "</table>";
}
?>

</center>