Is there any way to add pagination to a table, which fetches data from database?

732 Views Asked by At

I am experiencing huge trouble with table pagination. I searched every YouTube video, 10 pages of Google with "Table pagination", but none worked for me. My table has Semantic UI styling (class) and fetches data from Database. I have no clue, how to add pagination to this table. Also I tried JQuery plugins and so on, but that doesn't work.

1

There are 1 best solutions below

13
On BEST ANSWER

You can try to use datatables plugin. It comes with lots of features along with pagination options.

HTML file

<div>
  <table id="myTable">
    <thead> <tr>..</tr></thead>
    <?php
        Use php to populate table 
        foreach row fetched from database table
        {
        ?>
         <tr>
             <td>data1</td> 
             <td>data1</td>
         </tr>
        <?php
        }

    ?>

</div>


.....

In JS

$(document).ready(function() {
    $('#myTable').DataTable( {
        "ordering": false,
        "info":     false,
        ....
    } );
} );