Testing for no result ?
Posted: Tue Apr 06, 2010 11:07 am
Hi all,
I have a little block of code which lists courses that members have signed up for.
It looks like this:
having tried a few things and done some research I can't seem to find the right syntax to test for "no result" and post a message like
"you have not signed up for any courses yet".
Any suggestions ?
Best wishes
Monty
I have a little block of code which lists courses that members have signed up for.
It looks like this:
Code: Select all
<?php $id = mysql_real_escape_string($id);
$id = eregi_replace("`", "", $id);
$query = sprintf("SELECT c.* FROM students_to_courses stc INNER JOIN courses c ON stc.course_fk = c.course_id WHERE stc.student_fk = '$id'");
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
$tutor = $row['tutor_fk'];
$course_name = $row['course_name'];
$course_descriptoin = $row['course_description'];
$course_list = '<a href="coursework.php?courseName=' . $course_name . '" class="Times19">' . $course_name . ' </span><span class="Times19"> course work page</span> <br /></a>';
print $course_list;
}
?>having tried a few things and done some research I can't seem to find the right syntax to test for "no result" and post a message like
"you have not signed up for any courses yet".
Any suggestions ?
Best wishes
Monty