i'm struggling with adding pagination with php to my search results. Currently I search on index.php for a term and it takes me to search.php with a list of results that match from my database. This part works fine but i'd like it to show 10 results per page rather than every result on the same page. How do I achieve this? I've taken a look here and here but my code is a little different and i'm struggling to implement the suggestions. Any help would be greatly appreciated, even if to just point me in the correct direction.
<?php
if (isset($_POST['submit-search'])) {
$search = mysqli_real_escape_string($conn, $_POST['search']);
$sql = "SELECT * FROM people WHERE location LIKE '%$search%'";
$result = mysqli_query ($conn, $sql);
$queryResult = mysqli_num_rows($result);
echo " ".$queryResult." RESULTS";
if ($queryResult > 0){
while ($row = mysqli_fetch_assoc($result)){
echo "<div>
<h3>".$row['firstname']."</h3>
<p>".$row['lastname']."</p>
<p>".$row['location']."</p>
<p>".$row['profession']."</p>
</div>";
}
}
}
?>