I have piece of php code that gets and displays the data saved in a mysql table in separate elements. But my problem is that when the number of elements is bigger than an amount, the page becomes too slow when scrolling so I want to separate these elements into two or more pages to prevent the page to become slow. What should I do?
Here's is a piece of my code :
<?php
$serverName = "localhost";
$username = "User";
$password = "Password";
$database = "db";
$conn = new mysqli($serverName, $username, $password, $database);
if ($conn->connect_error) {
echo "Failed to connect to the server";
}
$sql = "SELECT row_1, row_2, row_3 FROM table";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<tag>" . $row["row_1"] . ", " . $row["row_2"] . ", " . $row["row_3"] . "</tag>";
}
}
?>
If anyone knows the way to do that, please reply me. Thanks