我想從mysql表中填充下拉列表。我能夠成功地填充它。但是當我在提交表單後嘗試檢索數據時,我無法檢索選定的值。誰可以幫我這個事?PHP和MySQL多選擇下拉列表
$authorDB=new AuthorDB();
$myArr =$authorDB->retrieveAuthors();
echo '<tr>
<td rowspan="3"><div style="position: relative;">Author</div></td>
<td>
<select name="selAuthor" id="$selAuthor" multiple="multiple" size="3">';
foreach ($myArr as &$s_author)
{
echo '<option value='.$s_author.'>'.$s_author.'</option>';
}
'</select>
</td>
</tr>'
enter code here
,並提交表單
$a_SelectedAuthors[]=$_POST["selAuthor"];
$nAuthors = count($a_SelectedAuthors);
echo '<h1> Count :'.$nAuthors.'</h1>';
for($i=0; $i < $nAuthors; $i++)
{
echo($a_SelectedAuthors[$i] . " ");
}
你應該給我們更多的細節?你是否$ _POST ['selAuthor']是空的?如果是,您是否檢查過您沒有使用GET方法表單? – AsTeR 2012-03-07 07:19:34