我在文件 showList.php 中写了以下表格,它从数据库中选择项目并在下拉列表中显示它们:
<form id="selForm" name="selForm" action="index.php" method="post">
<select name="selection" id="selection">
<option id="nothingSelected" >--Choose form---></option>
<?php
$con=mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("myDatabase",$con);
$result = mysql_query("SELECT * FROM formsTable");
while($row = mysql_fetch_array($result))
{
$selection_id=$row['id'];
if($_POST['selection']==$selection_id)$selElement="selected";
echo "<option id='$selection_id' name=\"sectionid\" value='$selection_id' >";
echo $row['nummer'] . " " . $row['titel']. " ";
echo "</option>";
}
?>
</select>
<input type="button" value="load form" onClick="validateForm(document.selForm)">
<input type="button" value="delete form" onClick="deleteForm(document.selForm);">
</form>
我将此文件包含在 index.php 中,如下所示:
<?php include('showList.php');?>
现在,当我调用 index.php 时,找到的表单列表将显示在下拉列表中。
这在 Firefox 中运行良好,我的问题是当我在 internetexplorer 中调用 index.php 时,出现以下错误:
Notice: Undefined index: selection in C:\path\showList.php on line 43
第 43 行是:
if($_POST['selection']==$selection_id)$selElement="selected";
正如您在上面的表格中看到的那样。任何想法?