Prevent 'Warning: Invalid argument supplied for foreach() in ...' for get_courses_page function when there are no courses in the required category.

This commit is contained in:
dwoolhead
2006-09-22 11:15:10 +00:00
parent b4713311d4
commit 12490fc2b3
+6 -4
View File
@@ -576,11 +576,13 @@ function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c
}
// pull out all course matching the cat
$courses = get_records_sql("SELECT $fields
$visiblecourses = array();
if (!($courses = get_records_sql("SELECT $fields
FROM {$CFG->prefix}course c
$categoryselect
ORDER BY $sort");
$visiblecourses = array();
ORDER BY $sort"))) {
return $visiblecourses;
}
$totalcount = 0;
if (!$limitnum) {
@@ -1515,4 +1517,4 @@ function category_parent_visible($parent = 0) {
}
// vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
?>
?>