Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • L lab-exercises
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 2
    • Issues 2
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • data-networks-web
  • lab-exercises
  • Wiki
  • lab 14

Last edited by Dan McQuillan Feb 23, 2018
Page history
This is an old version of this page. You can view the most recent version or browse the history.

lab 14

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

Clone repository
  • Home
  • lab 1
  • lab 12
  • lab 13
  • lab 14
  • lab 15
  • lab 17
  • lab 18
  • lab 2
  • lab 20
  • lab 3
  • lab 4
  • lab 5
  • lab 6
  • lab 7
View All Pages