Hi, i am using this code below to generate my drop down box (all the select statements and everything are fine)
[code=php]
<select name=”Type” id=”Type”>
<option>Please Select</option>
<?PHP
//fill in the categories
while ($row = mysql_fetch_array($type_res)) {
extract($row);
echo “<option value=’$Type’>$Type</option>n”;
}
?>
</select>
This works fine it populates the drop down box and everything its great.
what i have done below is put in an if script where if $Sub_Type is equal to $Type then it will echo selected so that, it will show what is in the database
so u know $Type is pulling from a different database to $Sub_Type and $Type is only to populate the drop down. what is happenen is i have a query to retrieve $sub_type from a product database and this is for an edit screen. so i need them to be able to change it but only to things populated from the $Type
[code=php]
<option>Please Select</option>
<?PHP
//fill in the categories
while ($row = mysql_fetch_array($type_res)) {
extract($row);
echo “<option value=’$Type’ <?PHP if($Sub_Type==$Type) echo”selected”;>?>$Type</option>n”;
}
?>
</select>
This code works when i am not doin an arrary but the array messes it up i beleive becuase of the echo coz i usualy do this
[code=php]
<select name=”sex”>
<option value=”Male” <?php if($sex==”Male”) echo “selected”; ?>>Male</option>
<option value=”Female” <?php if($sex==”Female”) echo “selected”; ?>>Female</option>
</select>
Any ideas y it aint working ?
Thanks Adam