hi all i i have created a drop down lookup table which queries a database, although im trying to get the menu to work that if a value already exists in a different table then to have this item automatically selected, $origr is the code that already exists.
Many thanks
<?
print "<form action=\"advisers.php\" method=\"post\">
<select name=\"RegCode\">";
for ($i=0; $i<$number; $i++) {
$RegCode = mysql_result($result2,$i, "RegCode");
$Registrar = mysql_result($result2,$i, "Registrar");
$block.= "<option value=\"$RegCode\"";
if($origr == $RegCode)
$block.=" Selected";
$block.=">$Registrar</option>";
}
echo "$block";
?>
*EDITED*
Hi played around and changed it to this which seems to be doing the job but i was expecting the wording selected to be next to the item in the drop down is this not the case!!
Cheers
print "<option value=".$RegCode;
if ($RegCode==$origr)
{
print " selected ";
};
print ">".$Registrar."</option>\n";
};