Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Mar 2009
    Posts
    120
    Thanks
    13
    Thanked 3 Times in 3 Posts

    How to page records?

    how can i page mysql selected records? for example, i want each page to have only 10 records.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Pagination is language dependant. MySQL has the advantage of a LIMIT clause, but by itself its pointless (for pagination purposes). What language are you developing in?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    Regular Coder
    Join Date
    Mar 2009
    Posts
    120
    Thanks
    13
    Thanked 3 Times in 3 Posts
    Code:
    What language are you developing in?
    Html/Php.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    I have a PHP5 pagination class posted in the snippets. Its somewhat advanced and assumes that whomever is incoporating it is familiar with callback routines and data handling.

    Pagination is a rather simple process, but does require calculations in order to determine where to draw from and how far to go (recordcount wise). For this reason, it is really easy to get lost.
    Here is a pretty good link I found on about: http://php.about.com/od/phpwithmysql...pagination.htm
    Its a simple example of pagination. Start easy, work up to complex

    Edit:
    Actually, I lied thats not a very good example. It makes use of long past deprecated features like register_globals.
    Specifically, the $pagenum doesn't exist, it should be in an if/else:
    PHP Code:
    if (!isset($_GET['pagenum']))
    {
        
    $pagenum 1;
    }
    else
    {
        
    $pagenum = (int)$_GET['pagenum'];

    Last edited by Fou-Lu; 04-10-2009 at 06:22 AM.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •