I want to display results randomly each time so in my $query3 I've added ORDER BY RAND(). That works - until you use the pagination. Page 2 displays a page 2 worth of random records from the total records. So an item could be shown on page 1 and 2 and 3 etc. What I want is for the total records to be created in a random order initially, but for the subsequent pages of pagination to display the balance of the total records from that original random set. Any thoughts appreciated. Thanks
<?php
//How many records per page
$rpp = 10;
//Check for set page
isset($_GET['page']) ? $page = $_GET['page'] : $page = 0;
//Check for page 1
if($page > 1){
$start = ($page * $rpp) - $rpp;
}else{
$start = 0;
}
//Query db for TOTAL records
$query2 = "SELECT id FROM posters WHERE display_on_web = 1";
$resultSet = mysqli_query($conn, $query2);
//Get total records
$numRows = $resultSet->num_rows;
//Get total number of pages
$totalPages = $numRows / $rpp;
//Query results
$query3 = "SELECT * FROM posters WHERE display_on_web = 1 ORDER BY RAND() LIMIT $start, $rpp";
$resultSet = mysqli_query($conn, $query3);
?>
<!-- end of pagination -->
<div class="container-fluid">
<div class="headspace"></div>
<div class="row">
<?php
$result = mysqli_query($conn, $query3);
$i = 1;
while ($data = mysqli_fetch_assoc($result)) {
?>
//Results are display here
<?php
for($x = 1; $x <= $totalPages=ceil($numRows/$rpp); $x++)
{
echo "<a href='?page=$x'><button class='pagination-button'> $x </button></a>";
}
?>
</div>