consolidation
no major new tasks this week. the main aim is consolidation, before we move on.
make sure you can implement the tasks from Lab-12 and Lab-13, namely:
- image upload
- admin / login
- search
now is the time to ask about those niggling problems or things that just didn't seem to work right.
extension
if you're up to date with those tasks, you can extend the search function with sorting and pagination, as covered in the last lecture.
sorting
your code for sorting could be something like
switch ($sort) {
case 1:
$sql .= " ORDER BY r.title";
break;
case 2:
$sql .= " ORDER BY a.last_name";
break;
default:
}
triggered by appropriate links in your search table, like
$content .= "<thead><tr><th><a href='?page=search&usersearch=$user_search&sort=1'>Title</a></th>";
pagination
as discussed in the lecture, this makes us of the mysql LIMIT clause e.g.
$sql = "SELECT * FROM Orders LIMIT 10 OFFSET 15";
This needs a bit of planning, as you will probably need to run one sql query to get the total number of pages, then a second one to pull out the results for the specific page of results you need. The code on last week's lecture slides will help