我试图列出所有在两个日期范围内不缴纳会费的学生。我首先从费用表中选择所有学生 id,然后将其存储在一个变量中,然后将这些 id 与学生表进行比较以列出所有非付费学生。但我的问题是它只适用于最后一个 id。假设我得到学生 id、1 和 2,那么查询仅适用于学生 id 2。这是代码。
$query = mysql_query("SELECT student_id,created FROM fee WHERE DATE(created) between '$sqldate1' AND '$sqldate2'");
while($rows = mysql_fetch_array($query)) {
$students = $rows['student_id'];
//echo $students;
$link = mysql_query("SELECT fee.class_id,fee.section_id,fee.student_id,fee.section_group,
fee.student_fee,fee.test_fee,fee.other_charges,fee.created,fee.fee_month,
class.class_id,class.class_name,section.section_id,section.section_name,student.id,
student.student_name FROM fee LEFT JOIN class ON(fee.class_id=class.class_id)
LEFT JOIN section ON(fee.section_id=section.section_id)
LEFT JOIN student ON(fee.student_id=student.id) WHERE student.id !='$students'")
or die(mysql_error());
$num = mysql_num_rows($link);
}