#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    44
    Rep Power
    15
    I have a table that currently holds over 1500 entries.

    When I select * from the table it always takes forever to load, so I set my site up to display 50 items per page. I can search through items 50 at a time forwards or backwards with no problem.

    But, now lets say I want to be able to skip the first 500 entries (10 pages). How do I set up dynamic pages so I can go straight to page 10 instead of having to press the "next" link 10 times? Thanks for any help.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    7
    Rep Power
    0
    In order to display in spesific item per page you need to rely on the database system to get maximize performance,
    example: in MySQL you do it by adding limit keyword in your sql syntax...

    SELECT * FROM Member ORDER BY MemberName
    LIMIT 0, 50

    it will select the first record until the next 50 records, if you want to skip the first 500 entries you can do it by

    SELECT * FROM Member ORDER BY MemberName
    LIMIT 500, 50


    Tata
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    44
    Rep Power
    15
    hmmm...

    ok. (tries to hide ignorance) How would I post that on a page?

    Like at the bottom of page one I want to have little page number links

    2 3 4 5... etc.

    That way when I'm on page 1, I can skip to page 5.... ya know like bulletin boards do.

    Would I just make each link a select statement? How could I do that dynamically so I don't have to add another 10 pages after another 500 entries? Am I making any sense (because sometimes I feel like I talk incircles)? Thanks for any help.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    44
    Rep Power
    15
    My friend helped me figure it out. The code is below for those in need of something similar.

    <?
    //initializing variable for 50-item display..
    $i = 1;
    $count=1;
    if (isset($pages))
    {$pagecount = 50 *($pages -1);
    }else{
    $pagecount=0;}

    $result= mysql_query ("SELECT * FROM table order by ID desc");

    //initializing loop to skip over already viewed items
    $startpoint=0;
    while ($startpoint != $pagecount && $row = mysql_fetch_array($result)){
    $startpoint++; }


    //initializing loop to show next 50 items...
    $currentcount=1;
    while ($currentcount<=50 && $row = mysql_fetch_array($result))
    {
    print $row["active"];
    $currentcount++;
    }
    //adding clauses for 1,2,3... links, allowing the number of already viewed items to carry over

    $tracker = mysql_query ("SELECT * FROM table order by ID desc");

    while ($row = mysql_fetch_array($tracker)){
    $count++; }

    $pages= $count/20;
    if ($count % 20 !=0) {
    $pages++;}

    while ($i <= $pages)
    {
    print('<a href="page.phtml?pages=');
    print($i);
    print('">');
    print($i);
    print('</a> ');
    $i++;
    }


    It may be a bit sloppy; but it works.

Similar Threads

  1. Stupid Beginners Question
    By nsorroll in forum C Programming
    Replies: 8
    Last Post: January 29th, 2004, 01:48 PM
  2. Stupid IO question
    By theperfectsoup in forum Python Programming
    Replies: 1
    Last Post: January 26th, 2004, 05:39 PM
  3. Replies: 14
    Last Post: January 15th, 2004, 02:37 PM
  4. Stupid performance question
    By avrfreak in forum PostgreSQL Help
    Replies: 3
    Last Post: December 16th, 2003, 03:44 AM
  5. Radio Buttons
    By Ulysses Freeman in forum HTML Programming
    Replies: 4
    Last Post: November 15th, 2003, 10:57 PM

IMN logo majestic logo threadwatch logo seochat tools logo