Currently, the codes I’ve done below are the codes that will only display the courses that have a tutor_id assigned to them. However, what I want is to display the courses that are not assigned the tutor_id as well as ‘No tutor has been assigned to this course’. Tutor_id is a NULL variable in the database.
(storing in navigation pages)
$arrItems = executeSelectQuery("SELECT * FROM course, category, tutor WHERE course.Category_id = category.Category_id AND course.Tutor_id = tutor.Tutor_id");
$totalDesign = executeSelectQuery("SELECT * FROM course, category, tutor WHERE course.Category_id = category.Category_id AND course.Tutor_id = tutor.Tutor_id");
$numrows = count($totalDesign);
$arrItems = executeSelectQuery("SELECT * FROM course, category, tutor WHERE course.Category_id = category.Category_id AND course.Tutor_id = tutor.Tutor_id ORDER BY course.Course_name ASC LIMIT $offset, $rowsPerPage");
Outer join provides just the functionality you are after. All
courses will be selected with some containing null values in the
Tutor_id field. Identify when this happens in your code and print
“No tutor has been assigned to this course” on these occasions.