SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Split pages

  1. #1
    SitePoint Enthusiast pff's Avatar
    Join Date
    Dec 2000
    Location
    Google PageRank: 6
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Split pages

    Hello,
    I'm taking some results from the mysql database and displaying them but I want to display a maximum of let's say 20 results at a time. The next results should show in a next page. I'd really appreciate it if you have any tutorials about this topic because I'm a real newbie in php & mysql as you see ...

    Thanks

    PS: I searched the forums but the results I found didn't really answer my question so I'm asking it ...
    pff | I am not what I am

    'Does he exist in the same way as I exist?'
    'You do not exist Winston,' said O'Brien.

  2. #2
    SitePoint Member
    Join Date
    Jul 2001
    Location
    Montréal, Québec
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    WOW!

    That's EXACTLY why I came here for! does anyone could help?
    ...gravity always wins...

  3. #3
    SitePoint Member
    Join Date
    Jul 2001
    Location
    Montréal, Québec
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ...gravity always wins...

  4. #4
    Victory shall be mine tubedogg's Avatar
    Join Date
    Mar 2001
    Location
    Medina, OH
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?

    if (!isset($page)) {
        
    $count mysql_query("SELECT junk FROM jame WHERE jumbo='jamboree'");
        
    $total mysql_num_rows($count);
        
    $startat 0;
        if (!isset(
    $atonce)) {
            
    $perpage 20;
        }
    } else {
        
    $startat = ($page)*$perpage;
    }
    $done = ($page)*$perpage;
    $page++;

    $myquery "SELECT junk FROM jam WHERE jumbo='jamboree' LIMIT $startat,$perpage";
    $results mysql_query($myquery);
    while (
    $row mysql_fetch_array($results)) {
        
    // process results
    }

    if (
    $total $atonce && $total $done) {
        echo 
    "<br><br><a href='$PHP_SELF?page=$page&perpage=$perpage&total=$total'>Get next $perpage results</a>";
    } else {
        echo 
    "<br><br>No more results.";
    }

    ?>
    Kevin


Bookmarks

Posting Permissions

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