hi I’m made a list for the category and the sub category
but on the one that i did the sub category is allways the same for both the categories
I know this because i didn’t do it in the code, i’m not sure how to do it so please help
the category and the sub category are stored in the database when you pick them and submit
this is the code:
<tr>
<td align="right">Category</td>
<td><label>
<select name="category" id="category">
<option value="cate1">Heating</option>
<option value="cat2">Plumbing</option>
</select>
</label></td>
</tr>
<tr>
<td align="right">Subcategory</td>
<td><select name="subcategory" id="subcategory">
<option value="<?php echo $subcategory; ?>"><?php echo $subcategory; ?></option>
<option value="Hats">cat1.sub1</option>
<option value="Pants">cat1.sub2</option>
<option value="Shirts">cat2.sub1</option>
</select></td>
</tr>
this is the php
[php] <?php
// Parse the form data and add inventory item to the system
if (isset($_POST[‘product_name’])) {
$pid = mysql_real_escape_string($_POST['thisID']);
$product_name = mysql_real_escape_string($_POST['product_name']);
$price = mysql_real_escape_string($_POST['price']);
$category = mysql_real_escape_string($_POST['category']);
$subcategory = mysql_real_escape_string($_POST['subcategory']);
$details = mysql_real_escape_string($_POST['details']);
// See if that product name is an identical match to another product in the system
$sql = mysql_query("UPDATE products SET product_name='$product_name', price='$price', details='$details', category='$category', subcategory='$subcategory' WHERE id='$pid'");
if ($_FILES['fileField']['tmp_name'] != "") {
// Place image in the folder
$newname = "$pid.jpg";
move_uploaded_file($_FILES['fileField']['tmp_name'], "../inventory_images/$newname");
}
header("location: inventory_list.php");
exit();
}
?>[/php]