$sql = "select custName from customer where active = 1 order by custName";
sult=mysql_query($sql);
echo"<select name='custNameColo'>";
while($row = mysql_fetch_array($result)) {
if($row['custName']==$_GET['defaultCust']) {
echo "<option value=".$row['custName']."selected = 'selected'>".$row['custName']."</option>";
}
else {
echo "<option value=".$row['custName'].">".$row['custName']."</option>";
}
}
echo "</select>";
我想設置一個默認值的下拉菜單,但它不能正常工作,請幫助我。不能降設置的默認值下拉菜單
你的選擇字段元素都有名字'custNameColo'&你'$ _GET [ 'defaultCust']'比較..在那裏再次檢查。 – Rikesh