Hi,
i was wondering how i code an option to be selected from a drop down box
In detail :
I want to edit a Product with it's informations, one of the informations is its Category. Categories are stored in another table, so i have a script that shows all those categories in a drop down box (code i use to add a product). When adding a product the corresponding category_id is saved within the product record.
Now i want to edit it, i make a form with all the corresponding info in the Value areas, but how do i make the code for the Option selected? So in the drop down box the category is selected wich corresponds to the category_id saved in the product record?
This is my code to make the drop down box of categories :
$querycat = "SELECT category_id,category FROM category ORDER BY category";
$resultcat = mysql_query($querycat) or die ("DB-fout:".mysql_error());
while($xcat = mysql_fetch_array($resultcat))
{
$listcat .= "<option value=\"$xcat[category_id]\">$xcat[category]</option>";
}
In the add_product page i then used this code to show the drop down box
<td>Product Category :</td>
<td><select name="category">
<option value=0></option>
<?
echo "$listcat"; ?>
</select>
But what do i use now for the edit page?
Thx in advance