Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Senior Member joncom11's Avatar
    Join Date
    Oct 2003
    Posts
    284
    Member #
    3532
    .
    Pixel Fuse - Signature webpage, just a spashpage.
    Flash Frogger - Frogger remake, animated/coded in Flash (incomplete/discontinued)
    Daase Art Studio - Homepage of David Daase, a Canadian landscape artist - image gallery/showcase.
    More links if I think of some...

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    You'll have to do something like this
    PHP Code:
    <?php
    $page 
    1;
    $numberPerPage 15;
    $first = ($page 1) * $numberPerPage ;
    $last $page $numberPerPage;
    $sql "SELECT * FROM search ORDER BY romid DESC LIMIT $first$last";
    $sqlTotal "SELECT FLOOR(COUNT(romid)/$numberPerPage) AS total FROM search";
    $total $row["total"]; // fill in the mysql stuff above
    ?>
    The page number will have to be passed by the link you click (e.g. << will like ?page=1 and < will link to ?page=[current page - 1] and the numbers (1, 2, 3, etc) will link to the respective page number.

    The $first and $last variables tell the Ssql query where to limit itself based upon the current page number and numberPerPage to display.

    Later, you can make the $numberPerPage variable settable in your page if you want. For now, keep it static so you can avoid having to set cookies or session variables.

    The $total variable will tell you the total number of pages you have to display. This will allow you to display the appropriate links at the bottom.

    Fill in the rest of the code and you can get this working yourself. If you continue to have problems, post back and we'll try to help out more.

  4. #3
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    This is real easy. To get the next 15, you simply change your select to : "select * from search order by romid desc limit 15,30" if you don't put the start from limit, it assumes 0 as is your original code.
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  5. #4
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    Transio... always gotta be outdoin me!
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  6. #5
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Sorry man, it's mod power. Once you're a mod, you can outdo the other members, too!! ;-)

  7. #6
    Senior Member joncom11's Avatar
    Join Date
    Oct 2003
    Posts
    284
    Member #
    3532
    .
    Pixel Fuse - Signature webpage, just a spashpage.
    Flash Frogger - Frogger remake, animated/coded in Flash (incomplete/discontinued)
    Daase Art Studio - Homepage of David Daase, a Canadian landscape artist - image gallery/showcase.
    More links if I think of some...

  8. #7
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    When I say fill it in, I mean like this:
    PHP Code:
    <?php
    // Page status variables
    $page $_GET["page"];
    if (
    $page ""$page 1;
    $numberPerPage 15;

    // Page index variables
    $first = ($page 1) * $numberPerPage ;
    $last $page $numberPerPage;

    // Total number of pages (from DB)
    $sqlTotal "SELECT FLOOR(COUNT(romid)/$numberPerPage) AS total FROM search";
    $query mysql_query($sql);
    if (
    $row mysql_fetch_assoc($query)) {
        
    $total $row["total"];
    } else {
        
    $total 1;
    }

    // Display the current page of images in a table
    $sql "SELECT * FROM search ORDER BY romid DESC LIMIT $first$last";
    $query mysql_query($sql);
    while (
    $row mysql_fetch_assoc($query)) {
        
    $romid $row["romid"];
        
    $name $row["name"];
        echo 
    "<div align=\"center\">";
        echo 
    "<a href=\"rompage.php?idrom=$romid\">";
        echo 
    "<img width=\"240\" height=\"160\" src=\"".$row["titlepicture"]."\" border=\"1\" />";
        echo 
    "</a>";
        echo 
    " ";
        echo 
    "<a href=\"rompage.php?idrom=$romid\">";
        echo 
    "<img width=\"240\" height=\"160\" src=\"".$row["screenshot"]."\" border=\"1\" />";
        echo 
    "</a>";
        echo 
    "</div>";
        echo 
    "<a href=\"rompage.php?idrom=$romid\">";
        echo 
    $name;
        echo 
    "</a>"
        echo 
    "<br>";
        echo 
    "<div align=\"center\">";
        echo 
    "<img width=\"494\" height=\"7\" src=\"images/showromsdivide.gif\" border=\"0\" />";
        echo 
    "</div>";
    }

    // Display the page links at the bottom of the page
    echo "<a href=\"$PHP_SELF?page=1\">&lt;&lt;</a>&nbsp;";
    echo 
    "<a href=\"$PHP_SELF?page=".$page-1."\">&lt;</a>&nbsp;";
    for (
    $i $page 5$i <= $page 5i++) {
        if (
    $i != $page) echo "<a href=\"$PHP_SELF?page=".$i."\">";
        echo 
    $i;
        if (
    $i != $page) echo "</a>";
        echo 
    "&nbsp;";
    }
    echo 
    "<a href=\"$PHP_SELF?page=".$page+1."\">&gt;</a>&nbsp;";
    echo 
    "<a href=\"$PHP_SELF?page=$total\">&gt;&gt;</a>&nbsp;";
    ?>
    That should work if there are no bugs... play with it and see what you can come up with.

    BTW... the "column" named "total" isn't a column in your database, it's an alias I'm giving to the calculation that counts the total number of pages of stuff in your database based upon the number of items you want to display per page. Hope that makes sense

  9. #8
    Senior Member joncom11's Avatar
    Join Date
    Oct 2003
    Posts
    284
    Member #
    3532
    .
    Pixel Fuse - Signature webpage, just a spashpage.
    Flash Frogger - Frogger remake, animated/coded in Flash (incomplete/discontinued)
    Daase Art Studio - Homepage of David Daase, a Canadian landscape artist - image gallery/showcase.
    More links if I think of some...

  10. #9
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    ok, try mysql_fetch_both() instead

  11. #10
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Actually, the problem seems to be with the query.

    Try echo $query; before you execute it to see what it's trying to execute.

    Then, run the query manually on your database to see what values you get.


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:38 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com