我正在为志愿者建立一个调度系统。做日程安排的女士希望看到在特定日期和时间内有哪些导师可用。她还想看看他们是否已经安排了一天。
由于第二个查询可能是一对多的关系,我不知道如何将其作为一个查询。
$sql2 = "SELECT `availID`, tutor.tutorID, tutorLastName, tutorFirstName, subjectID FROM tutorAvail\n"
. "INNER JOIN tutor USING (`tutorID`)\n"
. "INNER JOIN tutorSubjects USING (`tutorID`)\n"
. "WHERE `day` = ? AND `availEnd` >= ? and availStart <= ?\n"
. "and tutorSubjects.subjectID=?";
$tutors=$mysqli->prepare($sql2);
$tutors->bind_param('sssi', $row[1], $row[4], $row[3], $subID);
$tutors->execute();
$tutors->bind_result($availID, $tutorID, $tLName, $tFName, $subID);
while ($tutors->fetch()){
//get schedule for tutor)
$message="";
$sql3="Select day from masterSchedule where tutorID=%";
$tutSched=$mysqli->prepare($sql3);
$tutSched->bind_param('i',$tutorID);
$tutSched->execute();
$tutSched->bind_results($day);
while($tutSchedule->fetch()){
$message .=$day.', ';
}
?>
{page output removed for brevity)
<?php
}//end while tutormatch