Jump to content

Help modify pagination


Davie33

Recommended Posts

Hi i was hoping someone help me out to recode my pagination.My pagination for looks like this FIRST PREV ( Page 1 of 2 ) NEXT LAST

I would like it to be like this FIRST PREV (  1 2 3 4 5  ) NEXT LAST

 

This is my code if anyone can help me out thanks.

 

if (isset($_GET['page'])) {
       $pageno = $_GET['page'];
    } else {
       $pageno = 1;
    } 
    $result = yasDB_select("SELECT count(id) FROM games");
    $query_data = $result->fetch_array(MYSQLI_NUM);;
    $numrows = $query_data[0];
    $result->close();
    
    $rows_per_page = 20;
    $lastpage = ceil($numrows/$rows_per_page);
    $pageno = (int)$pageno;
    if ($lastpage < 1) {
        $lastpage = 1;
    }
    if ($pageno < 1) {
       $pageno = 1;
    } elseif ($pageno > $lastpage) {
       $pageno = $lastpage;
    } 
    $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;

<?php
    if ($pageno == 1) {
       echo ' FIRST PREV ';
    } else {
       echo ' <a href="index.php?act=managegames&page=1">FIRST</a> ';
       $prevpage = $pageno-1;
       echo ' <a href="index.php?act=managegames&page=' . $prevpage . '">PREV</a> ';
    } 
    echo ' ( Page ' . $pageno . ' of ' . $lastpage . ' ) ';
    if ($pageno == $lastpage) {
       echo ' NEXT LAST ';
    } else {
       $nextpage = $pageno+1;
       echo ' <a href="index.php?act=managegames&page=' . $nextpage . '">NEXT</a> ';
       echo ' <a href="index.php?act=managegames&page=' . $lastpage . '">LAST</a> ';
    }
    echo '<div style="clear:both;"></div></div>';
}
?>

Link to comment
https://forums.phpfreaks.com/topic/240753-help-modify-pagination/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.