I have been playing with some code but had little success, i have hacked it quite a lot.
Before i started removing things from the form, the code worked and it was to add products to a list to be displayed.

I am working on a separate page but only want a certain category to be displayed at a time. Using the options from the drop down menu will decided which category will be displayed.

I know what i want to do but not entirely sure how.

Any help would be great.


if (isset($_POST['category'])) {
$productlist = "";
$sql = mysql_query("SELECT * FROM products ORDER BY dateadded DESC");
$productcount = mysql_num_rows($sql); // count the output amount
if ($productcount > 0) {
	while($row = mysql_fetch_array($sql)){ 
             $id = $row["id"];
			 $productname = $row["productname"];
			 $price = $row["price"];
			 $dateadded = strftime("%b %d, %Y", strtotime($row["dateadded"]));
			 $productlist .= "Product ID: $id - <strong>$productname</strong> - $price - <em>Added $dateadded</em> &nbsp; &nbsp; &nbsp; <a href='inventoryedit.php?pid=$id'>edit</a> &bull; <a href='inventorylist.php?deleteid=$id'>delete</a><br />";
} else {
	$productlist = "None listed in store yet.";


<div id="inventory">
<?php echo $productlist; ?>


<div id="position" style="z-index: 1; width: 900px; height: 400px; position: absolute; top: 500px; left: 250px">	

          <form action='inventorycat.php' method='post' enctype='multipart/form-data'>
 	<select name='category' id='category'>
          <option value='anyoccasion'>Any Occasion</option>
          <option value='birthday'>Birthday</option>
          <option value='christmas'>Christmas</option>
          <option value='easter'>Easter</option>
          <option value='getwell'>Get Well</option>
          <option value='love&friendship'>love & friendship</option>
          <option value='m&fday'>Mother & Fathers Day</option>
          <option value='newbaby'>New Baby</option>
          <option value='thankyou'>Thank You</option>
          <option value='sympathy'>Sympathy</option>
          <option value='welcome'>Welcome</option>
          <option value='specialoffers'>**Special Offers**</option>
          <input type='submit' name='submitbtn' id='button' value='View Category' />

Thanks Brants91

mysql_query("SELECT * FROM products WHERE `category` = "$POST" ORDER BY dateadded DESC");

I am not sure that you have category id or name in the product table. The category table and product must be related with each other like foreign key in one table and another in primary.