I am using lazy loading to load data from database to device the limit is 20 but my problem lies when I pull the data from table because I have to order it by latest next date.
eg. I pull all data for today then tommorrow and then so on I cant use the id to keep track of what I loaded becuase the entries have different dates when entered
this is and example of my table. please note that my table can have thousands of entries
| id | name | date | time |
| 0 | name1 | 2018-09-30 | 01:00:00 |
| 1 | name2 | 2019-01-10 | 15:30:00 |
| 2 | name3 | 2019-09-30 | 10:20:00 |
| 3 | name4 | 2018-05-20 | 14:10:00 |
| 4 | name5 | 2020-09-02 | 01:30:00 |
| 5 | name6 | 2018-10-30 | 14:00:00 |
this is what my sql php script looks like. I know its not right but its an example of what im triying to do
SELECT * FROM table WHERE date >= '$today' AND id >= '$lastId' ORDER BY date ASC LIMIT 20
as you can see the id increments but the dates dont increment because it can be entered with any future date. I apologize for my bad english. Please can anyone help me
to paginate : you can use php or ajax and the last's is recommended:
<?php
$limit = 2;
if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * $limit;
$sql = "SELECT * FROM table ORDER BY field ASC LIMIT $start_from, $limit";
$rs_result = mysql_query ($sql);
?>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>title</th>
<th>body</th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysql_fetch_assoc($rs_result)) {
?>
<tr>
<td><? echo $row["field"]; ?></td>
</tr>
<?php
};
?>
</tbody>
</table>
finally add this to your html code: