-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplay_images.php
More file actions
36 lines (27 loc) · 1.03 KB
/
Copy pathdisplay_images.php
File metadata and controls
36 lines (27 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
// Database connection
$connection = mysqli_connect("localhost", "root", "", "platform");
// Fetch images ordered by their shuffled position
$sql = "SELECT * FROM images ORDER BY position ASC";
$query = mysqli_query($connection, $sql);
echo "<div style='display: flex; flex-wrap: wrap; gap: 10px; width: 50%; height: 75vh; overflow: hidden; margin: 2em auto;' box-shadow: 0 30px 20px rgba(0,0,0,0.6);>";
while ($row = mysqli_fetch_assoc($query)) {
echo "<img src='" . $row['image_url'] . "' alt='Image' width='80' height='80'>";
}
echo "</div>";
mysqli_close($connection);
?>
<html>
<body>
<script>
function reshuffleImages() {
fetch('reshuffle.php') // Calls a PHP script to reshuffle
.then(response => response.text())
.then(data => console.log("Reshuffled:", data)) // Debugging
.catch(error => console.error("Error reshuffling:", error));
}
// Run reshuffle every 10 seconds
setInterval(reshuffleImages, 10000);
</script>
</body>
</html>