This may be a silly question but not sure of a better way to do this at the moment - I am open to suggestions to a different way!
I have a webpage where I want simply post a collage of photos such as here. I have a MySQL database storing the location of all of my photos. I want these photos to be automatically loaded through a php if loop, i have this code:
$sql = "SELECT * FROM photo_gallery ORDER BY RAND()";
$result = mysqli_query($conn, $sql);
$queryResults = mysqli_num_rows($result);
if ($queryResults > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo "
<img src='/".$row['location']."' style='width:100%'>
";
}}
And this code works fine to load random photo saved in my database with no repeats. However, the way I have the photo gallery set up (if you view the w3schools template) the gallery is set up in 4 columns and this code can only be used to loop through photos once meaning only one column is shown. if I copy this code into each column it will obviously just cycle through the same photos it already had in the previous column (I want no-repeat photos)
Bottom line, how can I make a php loop through random photos with no repeats in a responsive photo gallery such as the w3schools?