I have made a dropdown menu where the user selects the kind of product:
$query="SELECT id, name FROM product ORDER BY name";
$result=mysql_query($query);
// $products.= "<option value=\"\">";
while($record=mysql_fetch_row($result)){
$product_id=$record[0];
$product_name=$record[1];
if($product_id==$p_product_id){
$selected="SELECTED";
}else{
$selected="";
}
$products.= "<option value=\"$product_id\" $selected>$product_name";
}
I am showing the dropmenu as followed:
<tr>
<td >Product</td>
<td ><select name=product style=\"width:150px;\">$products</select></td>
</tr>
No problem so far, based on the selection which is made i want to show different options, named categories, i have linked each category to an product ID.
$query="SELECT categorie.id, categorie.name, categorie.product_id, product.id FROM categorie LEFT OUTER JOIN product ON categorie.product_id = product.id WHERE active='1' ORDER BY order, omschrijving";
$result=mysql_query($query);
// $categories.= "<option value=\"\">";
while($record=mysql_fetch_row($result)){
$categorie_id=$record[0];
$categorie_name=$record[1];
$categorie_product_id=$record[2];
$product_id=$record[3];
if($categorie_id==$p_categorie_id){
$selected="SELECTED";
}else{
$selected="";
}
if($
$categorien.= "<option value=\"$categorie_id\" $selected>$categorie_name";
}
Dropdown:
<td >Categorie</td>
<td ><select name=categorie style=\"width:150px;\">$categorien</select></td>
I am kinda lost how i can edit my code, so i can show the correct category based on the choosen product (ID). Can someone give me tip to start with?