| Current Path : /var/www/html/mmishra/iws8/html/ilight/ |
| Current File : /var/www/html/mmishra/iws8/html/ilight/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',dated=now()
where id=$id");
} else {
mysql_query("insert into $tbl(code,description,dated)
values('$code','$description',now())");
}
} 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>Category Code</th><th>Category 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='3'><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->dated</td>";
}
echo "</tr>";
}
?>
</table>
</center>