1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Rep Power
    I have a large database and would like to split the results into 20 per page and with arrows to go to the next page and numbers to skip pages. But I'm not sure how to do it. I know I've seen an article on how to do this somewhere, anyone know one about this?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 1999
    Annapolis, Maryland US
    Rep Power
    One possible way is to execute the query and use mysql_affected_rows ($retrieved=mysql_affected_rows($link)) to see how many rows were returned from it. Then use MySQL's limit in the query for each successive page.

    If 144 rows were returned from the original query and this is stored in the $retrieved variable....


    if(empty($currval)) // this is the first query
    $query="select * from table limit $increment";
    else // all subsequent queries
    $query="select * from table limit $currval, $increment";

    query output

    if($currval < $retrieved)
    print"<a href="search.php3?currval=$currval&retrieved=$retrieved">See next results</a>";

    ...limit 20 will give you the first 20 rows returned from query

    ...limit 20, 20 will return twenty rows starting with the 21st row

    ...limit 40, 20 will give 41 through 60 and so on

    This is rough codestimate, but it may be able to help

Similar Threads

  1. splitting returned results in a select list....
    By ralphuk100 in forum PHP Development
    Replies: 16
    Last Post: February 2nd, 2004, 10:04 PM
  2. Limit results on 'left join' query
    By tippiedog in forum MySQL Help
    Replies: 1
    Last Post: November 12th, 2003, 08:58 AM
  3. Splitting db results into pages
    By rob46 in forum Perl Programming
    Replies: 2
    Last Post: November 6th, 2003, 07:46 AM
  4. Replies: 3
    Last Post: August 27th, 2003, 05:26 PM
  5. Splitting query results
    By ban5150 in forum PHP Development
    Replies: 5
    Last Post: July 21st, 2003, 02:44 AM

IMN logo majestic logo threadwatch logo seochat tools logo