我在PHP中调用选择值两次而不是一次。
请有人解决我的问题吗?
Html部分:
SELECT ADD_MONTHS (TRUNC (SYSDATE, 'YEAR'), -19 ) FROM DUAL;
QUERY RESULT
01-JUN-13
php代码:
<select name="mol[]" >
<option value="">Choose Mode of License</option>
<option value="standalone">Standalone</option>
<option value"wan">WAN</option>
<option value"lan">LAN</option>
</select>
答案 0 :(得分:0)
使用循环并生成一个选择框
//firs create an array with your options
$options[] = array(
'standalone' => 'Standalone',
'wan'=>'Wan',
'lan'=>'Lan'
);
//if already selected store the key to a variable
$selected = @$row['mol'];
echo "<select name='mol' class='mol'>";
//generate select box
foreach($options as $op => $key)
{
if($selected == $op)
{
echo " <option value='$op' selected = 'selected'>$key</option>";
}
else
{
echo " <option value='$op' >$key</option>";
}
}
echo "</select>";