I am building a scheduling system for volunteers. The woman doing the scheduling would like to see what tutors are available during a specific date and time. She'd also like to see if they are already scheduled for another day.
- My first thought was to find all the tutors that are available for the time slot ($sql2 below) and then do a while to display those results.
- Within the "while" I wanted to fetch the already scheduled information but I get an sql error.
Since the second query could be a one to many relationship, I wasn't sure how to do this as one query.
$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
 
    