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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2007
    Posts
    680
    Thanks
    319
    Thanked 1 Time in 1 Post

    Limit number of records being pulled in from database.

    Is there a way to limit the number of rows to pull in and display from a database?

    And then, add a link to display another page with more posts. Preferably on the same.

    My theory:

    while $i < 5 "get results";

    displayResults
    $i++
    }
    if (isset($_POST['nxtPage'])) {
    displayMore posts, from 5 - 10
    }
    if (isset($_POST['prvPage'])) {
    displaypreview posts
    }

    <form><input type="submit" name="prvPage"><input type="submit" name="nxtPage"></form>

    Just a rough idea ^ (Code not intended to be accurate Lol)
    Last edited by martynball; 01-28-2010 at 12:14 PM.

  • #2
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    use GET vars with pagination and a LIMIT on the mysql query?
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)

  • #3
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    As Jay says, Pagination is how you automatically add pages per number of rows.

    A LIMIT works like this,

    PHP Code:
    mysql_query("SELECT firstname FROM users WHERE id='$id' LIMIT 3"); 
    So if you had 5 records, it'd only show 3.
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?


  •  

    Posting Permissions

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