Results 1 to 4 of 4

Thread: Paginate MYSQL Table

  1. #1
    Lively Member Marthz's Avatar
    Join Date
    Nov 09
    Posts
    115

    Paginate MYSQL Table

    I've never really done this, and Im kinda stuck on it. Can anyone help me on how to paginate this table, with it only showing 10 results at a time.

    PHP Code:
    echo "<table border='1'>

    <tr>
    <th>Rank</th>
    <th>Name</th>
    <th>Level</th>
    <th>Fame</th>
    <th>Job</th>
    </tr>"
    ;
    $number 1;
    while(
    $row mysql_fetch_array($result))
      {

      echo 
    "<tr>";
        echo 
    "<td>" $number$number $number+"</td>";
      echo 
    "<td>" $row['name'] . "</td>";
      echo 
    "<td>" $row['level'] . "</td>";
      echo 
    "<td>" $row['fame'] . "</td>";
      echo 
    "<td>" $jobs[$row['job']] . "</td>";
      echo 
    "</tr>";
      }
    echo 
    "</table>";
    mysql_close($con);
    ?> 

  2. #2
    Moderator
    Join Date
    Jan 05
    Location
    Sydney
    Posts
    13,612

    Re: Paginate MYSQL Table

    Use a LIMIT on your query to set upper and lower boundaries to the results.

  3. #3
    Lively Member Marthz's Avatar
    Join Date
    Nov 09
    Posts
    115

    Re: Paginate MYSQL Table

    Quote Originally Posted by penagate View Post
    Use a LIMIT on your query to set upper and lower boundaries to the results.
    Already have that, but that doesn't help me on knowing how to paginate it. I've never done it before, and there aren't really any good tutorials that I can find.

    PHP Code:
    $result mysql_query("SELECT * FROM Characters WHERE gm=0 ORDER BY Level DESC LIMIT 100"); 
    Incase you wanted it.
    Last edited by Marthz; Oct 16th, 2012 at 01:31 AM.

  4. #4
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 08
    Location
    Trivandrum, Kerala, India
    Posts
    7,557

    Re: Paginate MYSQL Table

    Quote Originally Posted by Marthz View Post
    Already have that, but that doesn't help me on knowing how to paginate it. I've never done it before, and there aren't really any good tutorials that I can find.

    PHP Code:
    $result mysql_query("SELECT * FROM Characters WHERE gm=0 ORDER BY Level DESC LIMIT 100"); 
    Incase you wanted it.
    Marthz, you are missing the point. See this:
    Quote Originally Posted by penagate View Post
    Use a LIMIT on your query to set upper and lower boundaries to the results.
    Check this tutorials: http://www.phpeasystep.com/phptu/29.html

    It is written using legacy mysql_* functions. After you get the idea, rewrite it using mysqli or PDO. And always avoid mysql_* functions.


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD Athlon X2 5200+, ASUS Motherboard, 2 GB RAM, 400 GB HDD, Nvidia 8600 GT 512MB, 19.5" TFT(Wide), Creative 5.1 Home Theater

    Social Group: VBForums - Developers from India

    Skills: PHP, MySQL, jQuery, VB.Net, VB6, Photoshop...

Posting Permissions

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