How to build infinite scroll?

Hello! Did infinite scroll on this article here

only used mysqli instead of mysql.

Here's what happened:

$page = (int) (!isset($_GET['p'])) ? 1 : $_GET['p'];
$sql = "SELECT * FROM bookings ORDER BY id DESC";
$start = ($page * $limit) - $limit;

if( mysqli_num_rows(mysqli_query($connection, $sql)) --> ($page * $limit) ){
$next = ++$page;
$query = mysqli_query($connection, $sql . "LIMIT {$start}, {$limit}");

if (mysqli_num_rows($query) < 1) {
header('HTTP/1.0 404 Not Found');
echo 'Page not found!';
} ?>

 <?php while ($row = mysqli_fetch_array($query)): ?>

 <?php echo $row['uuid']?>
 <?php echo $row['surname']?>
 <?php echo $row['entry_date']?>
 <?php echo $row['exit_date']?>
 <?php echo $row['price']?>
 <?php echo $row['phone']?>

 <?php endwhile?>
 <?php if (isset($next)): ?>
 <div class="nav">
 <a href="booking.php?page=list&p=<?php echo $next?>">Next</a>
 <?php endif?>

But the download doesn't finish, re-entry loaded in a strange order.

Please help to understand what I did wrong.
July 2nd 19 at 13:44
0 answer

Find more questions by tags PHP