Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: 1,2,3,4,5 etc next page 6,7,8,9,10 and so on

  1. #1
    Join Date
    Mar 2007
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 1,2,3,4,5 etc next page 6,7,8,9,10 and so on

    Hi

    I want3d to know how do I achieve this.

    I have a php pagination and it shows everything fine and works nicely but it is missing one thing and that is the feature to continue from last number of previous page. lets say my page shows 10 users and it gives a number before each name like below:

    1: John
    2: Michael
    3: Shafiq
    4: Hedar
    5: Josh

    and then you click on page 2 and it should start from 6,7,8,9,10 but instead it counts back from 1,2,3,4,5. If someone could help me out here. Thats would be nice. Here is the pagination script.
    Code:
    $entries_per_page = "5";
    if(isset($_GET['page'])) {
    $page = $_GET['page'];
    } else {
    $page = 1;
    }
    $total_pages = ceil($count / $entries_per_page);
    $offset = ($page - 1) * $entries_per_page;
    $i = -1;
    
    for($i = 1; $i <= $total_pages; $i++) {
    echo "<a href=\"page$i\">$i</a> - ";
    }
    
    $qphoto = "SELECT * FROM `jhjkhjk` WHERE ft_id = '$ft_id' ORDER BY `pic_id` DESC LIMIT $offset, $entries_per_page";
    $rphoto = mysql_query($qphoto);
    $w = 0;
    if (!$rphoto){
    	die ("Could not query the database:<br />Houston! we have a problem here. ". mysql_error());
    }
    while ($p = mysql_fetch_array($rphoto, MYSQL_ASSOC)) {
    $w++;
    
    echo "$w: $p[name]";
    
    }
    The above code is juss snippet of my code. If any of you have any custom pagination that would do what I am trying to achieve then please let me know.

    Thanks alot.
    Last edited by shyne; 07-30-2007 at 06:33 PM.

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Use simple math: Depending on what the page value increment is, add the according value to your numbers.

    For example, say if $_GET["page"] is 0 then 5, 10 and so on.
    Code:
    ($i+($_GET["page"]))
    - Mike

  3. #3
    Join Date
    Mar 2007
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi
    thanks for the reply

    Can you please tell me where do I put the code in? lol sorrie but I just coudn't figure it out.

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    http://www.php-mysql-tutorial.com/php-mysql-paging.php

    Everything you need to know should be there.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Mar 2007
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks alot I luv dat tutorial. I actually changed it to that but I still am struggling with my above problem. If some one could show where to put the code in to make et work. That wud b nice.

    Thanks

  6. #6
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Slang: U ned to put it where u want 2 page stf.

    Proper: You need to put it where you want to put the pagination stuff.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  7. #7
    Join Date
    Mar 2007
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    OK LOL

    But you guys are not getting what I am saying here. I need to know how can I make the numbered list in the pagination to continue from where it left off on the previous page. Lets say I have 5 users in the first page and they start off like this:
    1. Michael
    2. John
    3. Ali
    4. Mushi
    5. Heather

    And then page 2 it should start like this:

    6. Henry
    7. Tom
    8. Kim
    9. Sara
    10. Kelly

    But now I don't know what code to put where in my pagination code. Thats what I am asking if someone could tell me where to put what to make it work, since the second page starts back from 1 instead of continuing from where the last result was previous page.

    Thanks

  8. #8
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Where are you getting this from?
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  9. #9
    Join Date
    Mar 2007
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by tech_support View Post
    Where are you getting this from?
    If I got your question correctly then I am getting it from MYSQL database using PHP, but if you question was asking me something else then I didn't get your question.

  10. #10
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Ah. How are your tables sorted? You'll need to setup your SQL line with LIMIT 10 etc.

    As djr33 linked before, here's a good tutorial on how to do it.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

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
  •