PHP Page Numbers on footer

Discussion in 'PHP' started by trueuk, Oct 1, 2012.

  1. #1
    Hey Guys,..

    If there is guru that has a few mins spare I would be grateful for some help..

    I have an admin panel that has page numbers on the footer, but need these to be a little smarter as people are starting to really use my site now..

    here is the snippet of code that needs fixing..

    echo "</table>";
    echo "<table width='100%'>";
    echo "<tr>";
    echo "<td>THERE ARE $num_of_users USERS</td>";
    echo "<td>";
    if ($_GET['page'] == 0){
    } else {
    echo "<a href='-1212/admin.php?page=$prevpage'>PREV</a>";
    }
    for ($i = 0; $i < $pages; $i++){
    echo "<a href='-1212/admin.php?page=$i'> $i </a>";
    }
    if (($_GET['page']) == $pages){
    } else {
    echo "<a href='-1212/admin.php?page=$nextpage'>NEXT</a>";
    }
    echo "</td>";
    echo "</tr>";
    echo "</table>";

    Which shows: USERS Previous 1 2 3 4 5 6 7 8 9 10 11 12 13 14 All the way over here... And here... Next

    But I have over 90 pages now and things are starting to get a little crazy on that footer.. :(

    Any suggestions? Something like, maybe it shows blocks of 10 or 20??

    Like they do on here at the bottom right of the topic page here.


    Like I said above, if someone has a few mins spare, I would be very grateful for the help..

    Much Apreciated

    Lee
     
    trueuk, Oct 1, 2012 IP
  2. capitalmind

    capitalmind Banned

    Messages:
    204
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You s hould break the loop when it reaches to particular figure say 40 or 50 you can use break statement to come out of the loop using if statement
     
    capitalmind, Oct 1, 2012 IP
  3. Web Solutions

    Web Solutions Peon

    Messages:
    64
    Likes Received:
    1
    Best Answers:
    5
    Trophy Points:
    0
    #3
    You can add two simple if statements within your for loop and limit printing out those numbers to a certain range.
     
    Web Solutions, Oct 2, 2012 IP
  4. Drent123

    Drent123 Peon

    Messages:
    105
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Footer used for replacement of a long content by a short content.
     
    Drent123, Oct 4, 2012 IP
  5. Vick.Kumar

    Vick.Kumar Active Member

    Messages:
    138
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    90
    #5
    I think what your more after is pagination?
     
    Vick.Kumar, Oct 5, 2012 IP