<select>数据传递的问题<br>inquire.html<br><br><br> <title>inquire the classroom</title> <br><br><br><br><h1>CRMS - Inquire the classroom</h1> <br><form action="inquire_classroom.php" method="post"> <br><table border="0"> <br><tr> <br> <td>Classroom ID</td> <br> <td> <br> <select name="lesson_id"><br> <option value="1">1</option> <br> <option value="2">2</option> <br> <option value="3">3</option> <br> <option value="4">4</option> <br> <option value="5">5</option> <br> <option value="6">6</option> <br> <option value="7">7</option> <br> <option value="8">8</option> <br> <option value="9">9</option> <br> <option value="10">10</option> <br> <option value="11">11</option> <br> <option value="12">12</option> <br> <option value="13">13</option> <br> <option value="14">14</option> <br> <option value="15">15</option> <br> </select><br> </td> <br> </tr> <br><tr> <br><td colspan="2"><input type="submit" value="Register"></td> <br> </tr> <br> </table> <br> </form> <br><br><br><br>inquire_classroom.php<br><br><br> <title>inquire the classroom</title> <br><br><br><h1>CRMS - Inquire the classroom</h1> <br><?php <br /> // create short variable names<br> $lesson_id=$_POST['lesson_id'];<br><br>$con = mysql_connect("localhost","root","");<br>//通过服务器locahost建立连接,用户名为root,无密码<br><br>if (!$con)<br> {<br> die('Could not connect: ' . mysql_error());<br> }//如果不成功,显示错误<br>mysql_select_db("crms", $con);//选择数据库<br><br>if (!mysql_select_db("crms", $con)) die(mysql_error()); <br><br>$search_lesson_id = "SELECT * FROM use2 WHERE lesson_id = '{$lesson_id}'";<br>$result = mysql_query($search_lesson_id,$con);<br>if (!$result)<br> {<br> die("The lesson does not exist.");<br> }<br><br>while($row = mysql_fetch_array($result))<br> {<br> echo $row['Cno'];<br> echo $row['CID'];<br> echo "<br>";<br> }<br><br>mysql_close($con);<br>?><br><br><br>下拉框选择了一个值提交后,出现<br>Notice: Undefined index: lesson_id in D:\xampp\htdocs\inquire_classroom.php on line 9<br>D301001 的错误。但是这里<select name="lesson_id">我不是已经定义了吗?<br><br><br><font color="#e78608">------解决方案--------------------</font><br> $lesson_id=$_POST['lesson_id']; 这样其实是OK的。<br>改一下php.ini的报错级别:<br>error_reporting = E_ALL & ~E_NOTICE <br><br>改后重启apache。 <br><font color="#e78608">------解决方案--------------------</font><br>notice并不是error,不影响结果。<br>想不出现notice,修改下php.ini中的错误提示级别就行 <div class="clear"> </div></select></select>