I'm making a website for myself to improve solving math equations. I inserted some equations to my database and now the website loads one random equation at a time.
<?php
$con=mysqli_connect("localhost", "", "", "math");
$rows=mysqli_query($con, "SELECT * FROM equations");
$rows = mysqli_num_rows($rows);
$num = rand(1, $rows);
$sql = "SELECT * FROM equations WHERE id='$num'";
$result = mysqli_query($con, $sql);
$datas = array();
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$datas[] = $row;
}
}
foreach ($datas as $data) {
echo $data['equation'];
}
?>
The problem is that as I'm putting new equations into the database it loads slower and slower. Is there anything I can do to make it load faster?