嗨,我一直在研究一个表格,其中有一个下拉菜单,它的值来自数据库。我的问题是提交表单后没有显示选择的值。可能是什么问题?
<select name="professional" />
<option value="">Choose one</option>
<?php
$result2 = mysql_query("SELECT * FROM professional");
while($row2 = mysql_fetch_array($result2))
{
$prc = $row2['name'];
$prof = $row2['prcno'] ."\t"."|\t". $row2['name'] ."\t"."|\t".$row2['profession'];
echo "<option value ='$prc'>$prof</option>";
}
?>
</select>
<select name="professional" disabled/>
<option value="">Choose one</option>
<?php
$result2 = mysql_query("SELECT * FROM professional");
$i=0;
while($row2 = mysql_fetch_array($result2))
{
$prc = $row2['name'];
$p1[$i] = $prc;
$prof = $row2['prcno'] ."\t"."|\t". $row2['name'] ."\t"."|\t".$row2['profession'];
$p2[$i] = $prof;
if($_POST['professional'] == $p1[$i])
{
echo "<option selected value ='$p1[$i]'>$p2[$i]</option>";
}
else
{
echo "<option value ='$p1[$i]'>$p2[$i]</option>";
}
}
?>
</select>