| Current Path : /var/www/cesa.co.za/php/ |
| Current File : /var/www/cesa.co.za/php/scecourses.php |
<h1>Course List</h1>
<script>
jQuery(document).ready(function() {
jQuery("#myInput").on("keyup", function() {
var value = jQuery(this).val().toLowerCase();
function matchesSearch(el) {
return jQuery(el).text().toLowerCase().indexOf(value) > -1;
}
jQuery("#courselist li").each(function() {
jQuery(this).toggle(matchesSearch(this));
});
// Hide category sections that have no matching courses, and their line breaks
// (use match logic, not :visible, so it works when parent was hidden)
jQuery("#courselist .course-list").each(function() {
var hasMatch = jQuery(this).find("li").filter(function() {
return matchesSearch(this);
}).length > 0;
jQuery(this).toggle(hasMatch);
var catId = jQuery(this).data("cat-id");
if (catId) {
jQuery("#courselist #line-break-" + catId).toggle(hasMatch);
}
});
});
});
</script>
<input type="text" name="quicksearch" id="myInput" placeholder="Enter keywords to search the course list" size="40" class="printhide">
<?php
include('inc_db.php');
?>
<ul id="courselist">
<?php
$sql = "SELECT SchoolCourses.CourseName, MAX(SchoolCourses.SchoolCourseID) AS SchoolCourseID,
MAX(SchoolWebCategories.WebCategoryID) AS WebCategoryID,
MAX(SchoolCourses.Category) AS Category
FROM SchoolCourses
INNER JOIN SchoolEvents ON (SchoolCourses.SchoolCourseID=SchoolEvents.SchoolCourseID)
LEFT OUTER JOIN SchoolWebCategories ON (SchoolEvents.WebCategory=SchoolWebCategories.WebCategoryID)
WHERE CurrentlyOffered=1
AND (SchoolWebCategories.WebCategoryID != 11 OR SchoolWebCategories.WebCategoryID IS NULL)
AND SchoolCourses.Archived = 0
GROUP BY CourseName
ORDER BY SchoolCourses.Category, CourseName";
// echo 'Please ignore debug info: ' . $sql . '<br>';
//die();
$queryresult = mysql_query($sql) or die(mysql_error() . " " . $sql);
$category = '';
$firstLine = true;
echo '<div>';
while ($row = mysql_fetch_array($queryresult)) {
if ($row["Category"] != $category) {
echo '</div>';
$catId = strtolower(str_replace(' ', '-', trim($row["Category"])));
$catId = preg_replace('/[^a-z0-9-]/', '-', $catId);
$catId = trim(preg_replace('/-+/', '-', $catId), '-');
if (!$firstLine) {
echo '<p id="line-break-' . $catId . '"> </p>';
}
$category = $row["Category"];
echo '<div class="course-list" id="cat-' . $catId . '" data-cat-id="' . $catId . '">';
echo "<h4>" . $category . "</h4>";
$firstLine = false;
}
echo "<li><a href='/sce/school-course?courseid=" . $row["SchoolCourseID"] . "'>"
. $row["CourseName"] . "</a></li>";
} //while
?>
</ul>
<?php
mysql_close();