| Current Path : /var/www/html/mmishra/iws8/html/ilight/ |
| Current File : /var/www/html/mmishra/iws8/html/ilight/stsuppliers.inc |
<h3>Supplier Panel</h3>
<?php
$tbl = "st_suppliers";
$id = $_REQUEST["id"];
$firm_name = $_POST["firm_name"];
$address = $_POST["address"];
$contact = $_POST["contact"];
$email = $_POST["email"];
$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 firm_name='$firm_name',address='$address',contact='$contact',email='$email',dated=now()
where id=$id");
} else {
mysql_query("insert into $tbl(firm_name,address,contact,email,dated)
values('$firm_name','$address','$contact','$email',now())");
}
} else if ($_POST["submit"] == 'DELETE') {
mysql_query("delete from $tbl where id=$id");
}
?>
<center>
<table width='80%' border='1' style='border-collapse: collapse'>
<tr><th>No</th><th>Firm Name</th><th>Address</th><th>Contact</th><th>Email</th><th nowrap>Dated</th></tr>
<?php
echo "<tr><td><a name='new'>+</a></td>";
if (!$id) {
echo "<td><input type='text' name='firm_name' size='50' value=''></td>
<td><input type='text' name='address' size='50' value=''></td>
<td><input type='text' name='contact' size='30' value=''></td>
<td><input type='text' name='email' size='30' value=''></td>
<td nowrap>$dated<input type='hidden' name='id' value='0'></td></tr>
<tr><th colspan='6'><input type='submit' name='submit' value='SAVE'></th>";
} else {
echo "<td colspan='5'><a href='?pg=$pg&id=#new'>Supplier</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='firm_name' size='50' value='$o->firm_name'></td>
<td><input type='text' name='address' size='50' value='$o->address'></td>
<td><input type='text' name='contact' size='30' value='$o->contact'></td>
<td><input type='text' name='email' size='30' value='$o->email'></td>
<td nowrap>$dated<input type='hidden' name='id' value='$o->id'></td></tr>
<tr><th colspan='5'><input type='submit' name='submit' value='SAVE'></th>
<th><input type='submit' name='submit' value='DELETE'></th>";
} else {
echo "<th>$o->firm_name</th><td>$o->address</td><td>$o->contact</td><td>$o->email</td><td>$o->dated</td>";
}
echo "</tr>";
}
?>
</table>
</center>