I would use a JOIN instead of two separate DB queries
Code:
SELECT o.products_options_values_id, products_options_values_name from `products_options_values_to_products_options` AS o LEFT JOIN products_options_values AS v ON o.products_options_values_id = v.products_options_values_id WHERE o.products_options_id='$opt' ORDER BY products_options_values_name
Then your code will become
PHP Code:
$html = "<tr><td width='161px'>
$name
</td></tr>
<tr><td>
<SELECT name='$opt' onchange='document.m_srch.submit();'>
<OPTION value='not'>---</OPTION>";//print the name of the box and start the drop down
$sql = "SELECT o.products_options_values_id, products_options_values_name from `products_options_values_to_products_options` AS o LEFT JOIN products_options_values AS v ON o.products_options_values_id = v.products_options_values_id WHERE o.products_options_id='$opt' ORDER BY products_options_values_name";
$res = tep_db_query($sql);// get the values of all the options for that catagory
while($row = tep_db_fetch_array($res)){
//create the dropdown
$html .= "<OPTION value='$row[products_options_values_id]' ";
if($_GET[$opt] == $row['products_options_values_id']){
$html .= "selected='selected'"; // if the product has already been selected keep it selected!
}
$html .= ">$row[products_options_values_name]</OPTION>";
}
$mainhtml .= $html."</SELECT></td></tr>";
Bookmarks