I've been looking online and on StackExchange for this answer, but can't seem to get my head around it.
I am wanting to have a button on my website that when clicked, will load more reviews. Currently I am limiting the reviews to 10 per page.
I have managed to get the button to display when there are more than 10 reviews, but I am stuck on what to do with this button to actually get it to load more reviews.
Would someone be able to help me with this please?
Here's my code:
Review Page
<?php
require('../../private_html/db_connection/connection.php');
$id= $_GET['id'];
$start = 0;
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$sql = "SELECT reviews.*, user_accounts.display_name, user_accounts.profile_picture FROM reviews, user_accounts WHERE reviews.company_id=$id && user_accounts.account_number = reviews.account_number ORDER BY time_stamp DESC LIMIT $start,10";
$reviews = $conn->query($sql);
foreach ($reviews as $row) {
print "//--DISPLAY FORMAT GOES HERE --/";
}
$dbh = null;
}
catch (PDOexception $e) {
echo "Error is: " . $e-> etmessage();
}
?><?php
$offset=$start+10;
if($reviews->rowCount() > $offset){
echo "<button id='loadmore' name='loadmore'>Load More Reviews</button>";
}
?>