Web Analytics Made Easy -
StatCounter Pagination page results between the prev and next button - CodingForum

Announcement

Collapse
No announcement yet.

Pagination page results between the prev and next button

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pagination page results between the prev and next button

    Hi

    I am newbie in php, my website is working great, I addes pagination and this is working fine. Except I can get the page results not working like google does.I have it like this now, <<prev 1,2,3,4,5,6,7,8,9,10,11,12,13, etc etc etc next>> I like to have it like <<prev 1,2,3,4,5,6,7,8,9,10 next>>. Hope somebody can help me out. thx for reading and your input.

    PHP Code:
    <?php
    require_once('./include/connect.php');    

    $page $_REQUEST["page"];
    $amount 10;
    $start $page $amount;
    $currentpage $page 1;

    $queryamount $amount 1;
    $query "SELECT date, id1, id2, id3, id4, id5, id6, id7 FROM member LIMIT $start$queryamount";
    $response mysqli_query($link$query);


    $query2 "SELECT COUNT(*) as total FROM member";
    $response2 mysqli_query($link$query2);
    $row2 mysqli_fetch_assoc($response2);
    $totalpages ceil($row2['total'] / $amount);

    if(
    $response){
        
        echo 
    "<center>(You are on Page <b>$currentpage</b> of <b>$totalpages </b>) </center>";

        
    $result mysqli_query ($link,"select count(1) FROM member");
        if(
    $result) {
                
    $row mysqli_fetch_array($result);
                
    $total $row[0];
                echo 
    "<center>Currently there are <b>$total</b> entry's in the Database </center>";
        } 
        
        
        
    $i $amount;
        while(
    $row mysqli_fetch_array($response)){
            
    $i--;
            if(
    $i 0)
                break;        
            
            
        }
        

        
         if(
    $page 0) {
        
        echo 
    "<a href= '" $_SERVER["PHP_SELF"] . "?page=" . ($page-1) . "' class='button'><b> << Prev</b></a>&nbsp";
    }

    for(
    $i 1$i <= $totalpages$i++) {
        
    //echo "<a href= '" . $_SERVER['PHP_SELF'] . "?page=" . ($i-1) . "'>";
        
    if($i == $currentpage) {


        echo 
    "<span class=active_page>[" $i "]</span>";
            
        } else 
            {
            
            
    //echo "<span class = page_nonactive>" $i "</span>";
            
            
    echo "<a href= '" $_SERVER['PHP_SELF'] . "?page=" . ($i-1) . "'>";
            
            echo 
    "<span class=nonactive>" .$i "</span>";

        } 
        echo 
    "</a> ";    
    }
     for(
    $i $currentpage 1$i <= min($currentpage 11$total_pages); $i++)
        if(
    $currentpage $totalpages) {
            echo 
    "<a href='" $_SERVER["PHP_SELF"] . "?page=" . ($page+1) . "' class='button'><b>Next >> </b></a>&nbsp";
            
            
        }
            
        
    } else {
        
        echo 
    "Couldn't issue database query";
        
        echo 
    mysqli_error($link);
    }
        
    mysqli_close($link);

    ?>
Working...
X