Detecting a blank row upon a return
Posted: Wed Nov 30, 2005 8:46 am
Hi all; I have this code that pulls out records from my DB where courseId matches in my courses and schedule table:
The code works fine if a match is made, but it falls over when no match is made. There is no error, but I'm writing the results into a table row, so when there is no match I want it to write out a blank cell, if there is, write out the cell and put in the result. The latter all works fine, but for the life of me I cannot get the IF to work that says "If $dboutput_dates contains no matching data, just write out a blank cell".
I've tried if ($dboutput_dates == false){ and if ($dboutput_dates == null){ and a few others but nothing.
As I am new to php/mysql, can I assume that even if there is no match made, something is returned? ie my IF will never be true? If so, how do I detect a 0 match?
cheers for any help
Frank
Code: Select all
$getDatesAssociatedWithThisCourse = "SELECT tblCourses.courseID,
tblCourses.duration, tblSchedule.day, tblSchedule.monthID, tblSchedule.yearID,
tblYear.year
FROM tblCourses, tblSchedule, tblYear, tblMonth
WHERE tblCourses.courseID = tblSchedule.courseID
AND tblSchedule.yearID = tblYear.yearID
AND tblSchedule.monthID = tblMonth.monthID
AND tblCourses.courseID = ".$link."
AND tblMonth.monthID = ".$idx." ORDER BY monthID ASC";
//echo $getDatesAssociatedWithThisCourse;
$dboutput_dates = mysql_query($getDatesAssociatedWithThisCourse);I've tried if ($dboutput_dates == false){ and if ($dboutput_dates == null){ and a few others but nothing.
As I am new to php/mysql, can I assume that even if there is no match made, something is returned? ie my IF will never be true? If so, how do I detect a 0 match?
cheers for any help
Frank