Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 36
  1. #16
    New Coder
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I got it figured out.. but My start = 0 should be showing 1-20 on the pagination but it's showing 1-21.. Very interesting!

  2. #17
    Regular Coder
    Join Date
    Mar 2012
    Posts
    168
    Thanks
    5
    Thanked 11 Times in 11 Posts
    Added the compatibility with url.

    PHP Code:
    <?php
    $cnt
    100//set to value in database
    if(isset($_GET['page']))
        
    $currentpage $_GET['page'];
    else
        
    $currentpage 1// Whatever you wanna use.
    $current 1;
    $limit 20//Or set to other value, or user defined.

    while($current <= $cnt)
    {
        
    $thislast $current $limit;
        
    $url "?page=" $currentpage;
        if(
    $thislast $cnt)
        {
              
    $thislast $cnt;
        }
        if(
    $current == ((($currentpage 1) * 20) + 1))
        {
            echo 
    '<p class = "paginationBold">'.  $current ' - ' $thislast '</p>';
        }
        else
        {
            echo 
    '<a class = "paginationLink" href = "http://localhost/testing.php?page=' . ((int)($current 20) + 1) . '">' .  $current ' - ' $thislast '</a>' ;
        }
            
    $current += $limit//Added this to update $current. Was missing.
    }
    ?>
    Quote Originally Posted by mfoland View Post
    I got it figured out.. but My start = 0 should be showing 1-20 on the pagination but it's showing 1-21.. Very interesting!
    1 + 20 = 21

    But you can easy fix that.
    Last edited by KULP; 11-28-2012 at 05:33 AM.

  3. #18
    New Coder
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Right.. My start is 0 because in my script above in the beginning if the start is 0 it'll show 1-20

  4. #19
    New Coder
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Also, I went to another page, and my first link for the 0-20 disappeared. hmm

    Edit.. nevermind on that. Was experiencing with the $current value! Still figuring out how to make it say 1-20 if i'm on start.. it does goes start = 2. I need them to be by 20..
    Last edited by mfoland; 11-28-2012 at 04:11 AM.

  5. #20
    Regular Coder
    Join Date
    Mar 2012
    Posts
    168
    Thanks
    5
    Thanked 11 Times in 11 Posts
    Try changing

    Code:
    $thislast = $current + $limit;
    to

    Code:
    $thislast = $current + $limit - 1;

  6. Users who have thanked KULP for this post:

    mfoland (11-28-2012)

  7. #21
    New Coder
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts
    That worked.. I'm learning.. Thanks!

    Now when I click the link instead of it going by one.. I need it to still go by 20.. My start needs to be 0 for the 1-20 records to show.. So 0 + 20 obviously but then to show the next record.. that's the hard part.. I do want to think it has to do with the link area.

  8. #22
    Regular Coder
    Join Date
    Mar 2012
    Posts
    168
    Thanks
    5
    Thanked 11 Times in 11 Posts
    Quote Originally Posted by mfoland View Post
    Now when I click the link instead of it going by one.. I need it to still go by 20..
    What? And sorry but I'm not going to code your entire site...

  9. #23
    New Coder
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I'm thinking while having the 1-20 say start = 0 the next would say that first number... example the 41-60 say start = 41.. I can think of it, but to code it, is the hard part, well with the pagination. It is a learning experience for me!

  10. #24
    New Coder
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts
    This is the only project I need help with.. How do I get the page to increase or decrease by say 20.. On the links I need it to echo the <?=$current?> so if I click 41-60 the page would say 41

  11. #25
    Regular Coder
    Join Date
    Mar 2012
    Posts
    168
    Thanks
    5
    Thanked 11 Times in 11 Posts
    Quote Originally Posted by mfoland View Post
    This is the only project I need help with.. How do I get the page to increase or decrease by say 20.. On the links I need it to echo the <?=$current?> so if I click 41-60 the page would say 41
    What do you mean by 'the page would say 41'

  12. #26
    New Coder
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by KULP View Post
    What do you mean by 'the page would say 41'
    ?page=41

    That!

    So when I click on the link it goes by 20s instead of one.

    EDIT.. I'll give you an example.. The default is page= 0 so 1-20 should be bold.. although it doesn't for that. But then if I click 21-40 the page variable will be ?page=21, and so on.

  13. #27
    Regular Coder
    Join Date
    Mar 2012
    Posts
    168
    Thanks
    5
    Thanked 11 Times in 11 Posts
    Quote Originally Posted by mfoland View Post
    ?page=41

    That!

    So when I click on the link it goes by 20s instead of one.
    That can be changed but... why?... Is the rest of the page already coded to work that way or something?

  14. #28
    New Coder
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by KULP View Post
    That can be changed but... why?... Is the rest of the page already coded to work that way or something?
    Yes it is..

  15. #29
    Regular Coder
    Join Date
    Mar 2012
    Posts
    168
    Thanks
    5
    Thanked 11 Times in 11 Posts
    Well you're almost there, just change a few things. I think you can play around with it enough.

  16. Users who have thanked KULP for this post:

    mfoland (11-28-2012)

  17. #30
    New Coder
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by KULP View Post
    Well you're almost there, just change a few things. I think you can play around with it enough.
    The only thing I could think of is if I change the +1 in the link to say $current it'd work, but it didn't even work.. That's why I sent the reply asking for help as to what to change.


 
Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

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