我有三个选项,你可以看到。我只需要课程选项和年份选项。现在我想获得它们的值,以便我可以将它们传递给我的查询。这里的问题是,他们已经根据不同的表格进行查询,当我试图将Section的$ _POST传递给一个变量并查询它时,错误表明未定义的索引。我该怎么办?由于
这两个选项的代码:
<div class="col-md-3 pull right">
<label>Course</label>
<select class="form-control" name="course" id="courseselect">
<?php
$query= mysqli_query($con,"SELECT * FROM course");
$numrows=mysqli_num_rows($query);
if($numrows !=0){
while($row=mysqli_fetch_assoc($query)) {?>
<option value="<?php echo $row['courseid'];?>"><?php echo $row['coursedesc'];?></option>
<?php }
}
?>
</select>
</div>
<div class="col-md-2 pull right">
<label>Year</label>
<select class="form-control" name="year">
<?php
$query= mysqli_query($con,"SELECT * FROM year");
$numrows=mysqli_num_rows($query);
if($numrows !=0){
while($row=mysqli_fetch_assoc($query)) {?>
<option ><?= $row['yearnum'];?></option>
<?php }
}
?>
</select>
</div>
,这是我的查询
$cid=$_POST['courseid'] //the value from the Course option
SELECT t1.studentno, t1.firstname, t1.lastname, t1.yearid, t2.coursedesc
FROM
students as t1
INNER JOIN course as t2
ON $cid=t2.courseid
LEFT JOIN paidstudents as t3
ON t1.studentno = t3.studentno
WHERE
t1.studentno IS NOT NULL
AND t3.studentno IS NULL
$ CID说未定义指数
我想更换courseid和yearid进入后面的数值。谢谢
关于php/html部分的select:你的表单是什么样的?在PHP部分:你如何获得$ vars(post/get方法)以及如何处理验证? – OldPadawan
您发布并使用选定值的PHP代码在哪里? –
这我的表单看起来像https://ibb.co/bPKAbQ @OldPadawan – Blances