Hello:
On an edit page where I'm editing an Item that belongs to 1 category, but I want to give the person editing, the option of select a different category.
I'm having a little problem, because there are 4 categories in my categories table, but the drop down is only showing 3.
This is my QUERY
$query = "SELECT Category.cat_name,Category.cat_id,Items.item_id,Items.item_name,Items.item_desc,Items.item_specs,Items.item_price,Items.item_avail,Items.item_thumb FROM Category,Items WHERE Items.item_id = '$_GET[item_id]'";
// NOTE: item_id is passed by a link.
$result = mysql_query($query) or die ("Query Failed: " .mysql_error());
$row = mysql_fetch_array($result);
$item_id = $row["item_id"];
$item_name = $row["item_name"];
$item_desc = $row["item_desc"];
$item_specs = $row["item_specs"];
$item_price = $row["item_price"];
$item_avail = $row["item_avail"];
$item_thumb = $row["item_thumb"];
// I did each individual since im only editing ONE item and I don't need to do a while loop to get more.
THIS IS WHERE I HAVE A PROBLEM.
The Drop down only shows 3 Categories instead of 4! cat_id is in both the Items and Categories database and is related by cat_id... I wanted to only have to run 1 query instead of 2... maybe this was a mistake?
WHAT FOLLOWS IS THE HTML
Select a Category<br>
<select name="cat_id">
<?php
while ($categories = mysql_fetch_array($result)): // instead of { so I can exit php
$cat_id = $categories["cat_id"];
$cat_name = $categories["cat_name"];
?>
<option value="<?php echo $cat_id; ?>"><?php echo $cat_name; ?></option>
<?php endwhile; ?>
</select>
</div>
Any help you guys can provide would be awesome. Let me know 🙂