How to improve my pagination in php

0
Hi, I wrote a pagination in php some time ago now I have a problem with it this pagination is simple divides the total of lines of the database by the amount of links per page; but now the amount of lines in my database has grown and the paging is deforming my page, I would like to change it by putting a limit exp:

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 fix this?

similar to google pagination

    
asked by anonymous 04.01.2018 / 16:25

2 answers

1

You could use a paging plugin, such as pagination.js .

A small example of usage, taken from documentation , would look like this:

$('#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);
    }
})
    
04.01.2018 / 16:42
1

As @Juven_v said above you can opt for a Javascript library to page. But as your 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 pagination depending on the user's current page.

Example: Initially it could show 1, 2, 3, 4 ............ 49, 48, 50 and then change according to the current page.

    
04.01.2018 / 16:54