Hi
I have some code that has 2 querys to fill 2 dropdown boxes. I need to get an id from one depending on which selection is chosen, put it in a variable to use in the second query.
My code is below with comments of what I want to do.
//populate cat form dropdown box
$dd = '';
$r = mysql_query("SELECT cat_id, cat_label FROM categories");
if (mysql_num_rows($r)){
while ($d = mysql_fetch_assoc($r)){
$dd .= "\n\t<option value='{$d['cat_id']}'>{$d['cat_label']}</option>";
//I need to get cat_id into a variable($cat_id) from here and use it in the below query
}
}
//populate subcat form dropdown box
$op = '';
$r = mysql_query("SELECT name, product_id FROM cat_images WHERE cat_id = $cat_id");
if (mysql_num_rows($r)){
while ($d = mysql_fetch_assoc($r)){
$op .= "\n\t<option value='{$d['product_id']}'>{$d['name']}</option>";
}
}
Can anyone offer advice on this?
Thanks for looking
Glen