Brained Washed
Brained Washed

Reputation: 703

How can I implement dynamic pagination in PHP with this line of code?

I want to know how can I make this list inline from 1 to 1000 etc maybe with scroll will do, and base on my ouput the prev and 1 is not included, How can I fix this?

enter image description here

Here's the code I use:

echo 
        '<div class="pagination">
            <ul>
                <li>Prev</li>';
        if(isset($_SESSION['paging'])){
            $pages=$_SESSION['paging'];
            echo 
                '<li>'.$pages.'</li>';
        }
        else{
            echo 
                '<li>'.$pages.'</li>';
            $_SESSION['paging']=$pages;
            $_SESSION['paging1']=$pages;
        }
?>
        <li>Next</li>
    </ul>
</div>

Upvotes: 1

Views: 1491

Answers (1)

Ahmad Alfy
Ahmad Alfy

Reputation: 13371

This is a wrong approach ... It doesn't make sense serving 1k of pagination links! This is a horrible user experience and unnecessary load to the DOM

I would recommend you go like the approach I am listing below :

Say your current active page is #11

<|- Start <- Previous - 9 - 10 - 11 - 12 - 13  - Next -> Last -|>

Upvotes: 2

Related Questions