我目前在 php 中工作。在下面的代码中,我得到了未定义的索引:第 42 行的 subject_code 和未定义的索引:第 24 行的 course_code。所以任何人都可以帮助我。我试图删除错误,但我不能。所以任何人都可以帮助我。
<script language="javascript">
function changeSelection(value){
var length = document.getElementById("hai3").options.length;
if(value == 0){
for(var i = 1;i<length;i++)
document.getElementById("hai3").options[i].selected = "selected";
document.getElementById("hai3").options[0].selected = "";
}
}
</script>
<script language="javascript">
function check(elem) {
document.getElementById('dis').disabled = !elem.selectedIndex;
}
</script>
<?php
mysql_connect("localhost", "root", "") or die("Error connecting to database: ".mysql_error());
mysql_select_db("slseatapp") or die(mysql_error());
if($_POST['course_code']){
@$exam_name=$_POST['course_code'];
?>
<B>SELECT COURSE CODE</B> <select name="hai2" id="hai2">
<option>Select</option>
<?php
$query="SELECT distinct course_code FROM examcourse where exam_name = '$exam_name' ";
$result = mysql_query($query);
while($nt=mysql_fetch_array($result)) {
echo "<option value='".$nt['course_code']."'>".$nt['course_code']."</option>";
}
?>
</select>
<?php }
if($_POST['subject_code']){
@$subject_code=$_POST['subject_code'];
?>
<B>SELECT SUBJECT CODE</B>
<select name="hai3[]" id="hai3" multiple="multiple" onChange="changeSelection(this.value),check(this);">
<option value="0">Select All</option>
<?php
$query="SELECT distinct subject_code FROM coursesubject where course_code = '".$subject_code."' ";
$result = mysql_query($query);
while($nt=mysql_fetch_array($result)) {
echo "<option value='".$nt['subject_code']."'>".$nt['subject_code']."</option>";
}
?>
</select>
<?php }?>