1. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    i want search results to be limited to 10 records per page.

    say, if a search on a database return 95 records, i want the results to be formatted to 10 pages.

    how do i do that ?

  2. #2
  3. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    select * from table_name limit 10
    and for next page:
    select * from table_name limit 10, 10
  4. #3
  5. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    What you see in the last example is SQL's LIMIT and OFFSET functions. The syntax above is for MySQL. Other SQL DB's format it slightly differently:

    select * from table_name limit 10 offset 10

    Basically your SQL engine does the query and then returns only 10 records (the limit) starting with the 10th record in the query result (the offset).

    You can then display the entire query result on your page and know that it'll only have 10 lines. You'll need to set up a system for tracking the offset so you can create NEXT and PREVIOUS functions that simply +10 or -10 the offset and display the new results on a fresh page.

Similar Threads

  1. Replies: 11
    Last Post: February 21st, 2004, 06:48 AM
  2. include external page that uses cookies
    By micahbdavis in forum PHP Development
    Replies: 1
    Last Post: February 9th, 2004, 04:03 PM
  3. Replies: 0
    Last Post: February 8th, 2004, 10:11 PM
  4. how to limit my records..
    By fluke_tony in forum MySQL Help
    Replies: 2
    Last Post: February 1st, 2004, 09:55 PM
  5. passing the url from HTML page to a php
    By lordorkus in forum PHP Development
    Replies: 10
    Last Post: January 20th, 2004, 05:36 PM

IMN logo majestic logo threadwatch logo seochat tools logo