tags:

views:

34

answers:

2

I'm really unsure of how ordered results are displayed on a page like stack overflow questions. I know how to get the data from the DB but do i use a for each loop to display the data. And how can i paginate?

I know all about display logic on the databse end. What i mean is that i have the data ready but i do not know how to put in on the page to be displayed correctly.

Thanx

A: 

You need to use

GET parameters in your requests should determine the values applied to those statements.

Andy E
A: 

To order results, you should add a "ORDER BY" clause to your SQL statement. Specifically, for StackOverflow default view, it shows questions by date (with the most recent most). This implies that each question has the datetime which it is created tagged to it.

As for pagination, here's a general outline of the code

  1. Find total number of records
  2. Decide how many records per page
  3. Find out how many pages (record per page/page)
  4. Check what's the current page number
  5. Calculate the parameters to add to the LIMIT clause in the SQL statement. The start record should be current page * records per page.
Extrakun