Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.