How to improve my php pagination

Asked

Viewed 131 times

0

Hi, I wrote a php pagination some time ago now I have a problem with it this pagination is simple splits the total number of rows of the database by the amount of links per page; only now the amount of lines in my database has grown and the pagination is deforming my page, I would like to change it by placing an Exp limit:

page 1, page 2 and so on

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 56

how can I do this?

similar to google paging

2 answers

1


You could use a plugin for paging, for example, the pagination.js.

A small example of use, taken from documentation, would be so:

$('#demo').pagination({
    dataSource: [1, 2, 3, 4, 5, 6, 7, ... , 195],
    callback: function(data, pagination) {
        // template method of yourself
        var html = template(data);
        dataContainer.html(html);
    }
})

1

As @Juven_v said above you can opt for a Javascript library to page. But as its tag is in PHP the solution would be to implement a pagination using the LIMIT of the database. And another logic to control the total of the pagination depending on the current user page.

Example: Initially it could show like this 1, 2, 3 ,4 ......... 49, 48, 50 and go changing according to the current page.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.