<?php
include_once('includes/ffe/ffeheader.html');
include_once('includes/myclass.php');
require_once('includes/ffe/ffe_connect.php');
$op = stripslashes($_GET['op']);
$id = stripslashes($_GET['id']);
if (isset($_POST['add']) || isset($_POST['save'])) {
$error = false;
if (empty($_POST['category'])) {
echo '<p class="error_msg">Please enter category information!</p>';
$error = true;
}
$type = $_POST['type'];
$brand = $_POST['brand'];
$model = $_POST['model'];
if (!$error) {
if (isset($_POST['add'])) {
$query2 = "INSERT INTO ffecategory (type, brand, model)
VALUES (ucase('$type'),ucase('$brand'),ucase('$model'))";
} else {
$query2 = 'UPDATE ffevendor SET type=ucase("'.$type.'"),
contact=ucase("'.$brand.'"),
contact_no=ucase("'.$model.'") WHERE cat_id='.$_POST['hid'];
}
$result2 = @mysql_query($query2);
if (!$result2)
echo '<p class="error_msg">Error while saving supplier or brand!</p>';
else {
header ("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/vendors.php?op=".$_POST['hop']."&id=".$_POST['hid']);
exit();
}
}
} // isset($_POST['add'])hy
echo '<form action="vendors.php" method="post">
<input type="hidden" name="hop" value="'.$op.'" />
<input type="hidden" name="hid" value="'.$id.'" />
<table border="0" align="center" width="96%" bordercolor="#FFFFFF" bgcolor="#E0E0E0">
<tr bgcolor="#F0F0F0"><td class="ffetitle" colspan="3">Supplier / Brand</td></tr>
<tr bgcolor="#FFFFFF">
<td>
<table border="0" width="100%">
<tr>
<td width="80" valign="middle">
<table border="0" align="left" bordercolor="#999999" bgcolor="#999999" width="100%">
<tr bgcolor="#FFFFFF">
<td align="center"><a href="utilities.php" class="ffelink1">Return</a></td>
<td align="center"><a href="vendors.php" class="ffelink1">Add Category</a></td>
<td align="center"><a href="update.php" class="ffelink1">Update Category</a></td>
</tr>
</table>
</td>
<td align="right">
<!--
<table border="0" align="right">
<tr>
<td>
<input type="text" name="searchstring" size="20" maxlength="20" />
<input type="submit" name="search" value="Search" />
</td>
</tr>
</table>
-->
</td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="3">
<br><br>';
if ($op=="edit") {
$query = 'SELECT type,brand, model FROM ffevendor WHERE cat_id='.$id;
$result = @mysql_query($query);
if ($row = @mysql_fetch_array($result)) {
$type = $row[2];
$brand = $row[3];
$model = $row[4];
}
} else {
$type = $_POST['type'];
$brand = $_POST['brand'];
$model = $_POST['model'];
}
echo ' <table border="0" width="530" align="center" cellspacing="1">
<col width="100" align="right">
<col width="410" align="left">
[color=#FF0000]<tr><td>Category</td>
<td>';
$category = new WEMSControls();
$category->category($_POST['cat_id'],1);
echo ' </td>
</tr>[/color]
<tr><td>Type </td>
<td><input type="text" name="type" size="60" maxlength="60" value="'.$type.'"/></td>
</tr>
<tr><td>Brand </td>
<td><input type="text" name="brand" size="60" maxlength="60" value="'.$brand.'"/></td>
</tr>
<tr><td>Model </td>
<td><input type="text" name="model" size="30" maxlength="30" value="'.$model.'"/></td> </tr>
<tr>
<td colspan="2" align="center">
<br>';
if ($op=="add") echo ' <input type="submit" name="add" value=" Add " />';
else echo '<input type="submit" name="save" value=" Save " />';
echo ' </td>
</tr>';
echo ' </table>
<br><br>
<table border="0" width="99%" align="center" cellspacing="1" bordercolor="#ffffff">';
$query = 'SELECT * FROM ffecategory order by cat_id ASC';
$result = @mysql_query($query);
echo ' <tr bgcolor="#FFDDBB" align="center">
<td>ID</td>
<td>Category</td>
<td>Type</td>
<td>Brand</td>
<td>Model</td>
</tr>';
$bg = '#eeeeee';
while ($row = @mysql_fetch_array($result, MYSQL_NUM)) {
$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // switch the background color
echo '<tr align="left" bgcolor="', $bg, '">';
echo ' <td class="listtd">
<a href="vendors.php?op=edit&id='.$row[0].'">',$row[0],'</a>
</td>
<td class="listtd">
<a href="vendors.php?op=edit&id='.$row[0].'">',$row[1],'</a>
</td>
<td class="listtd">',$row[2],'</td>
<td class="listtd">',$row[3],'</td>
<td class="listtd">',$row[4],'</td>';
echo '</tr>';
} // while
echo ' </table>
<br>
</td>
</tr>
</table>
</form>';
include_once('includes/ffe/ffefooter.html');
include_once('includes/footer.html');
?>
- how can i let the category drop down appear? i want that the list of the drop down came from the database. im having a hard time to show the database list of CATEGORY for a drop down. Please i need help, really..
This post has been edited by raven21: 27 December 2009 - 10:43 PM

New Topic/Question
Reply




MultiQuote



|