-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgallery.php
More file actions
50 lines (43 loc) · 1.45 KB
/
gallery.php
File metadata and controls
50 lines (43 loc) · 1.45 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gallery - TechTrendz</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<?php include('header.php'); ?>
<!-- Upload Form -->
<section class="upload-form">
<h1>Upload Image</h1>
<form action="upload_image.php" method="POST" enctype="multipart/form-data">
<input type="file" name="image" required>
<button type="submit" class="btn">Upload</button>
</form>
</section>
<!-- Image Gallery -->
<section class="gallery-grid">
<?php
// Database connection
$db = new mysqli('localhost', 'root', 'jMm@0000', 'serversidetask');
// Check connection
if ($db->connect_error) {
die("Connection failed: " . $db->connect_error);
}
// Fetch images from database/
$result = $db->query($sql);
if ($result->num_rows > 0) {
// Output data of each row
while($row = $result->fetch_assoc()) {
echo "<div class='gallery-item'><img src='{$row['image_path']}' alt='Gallery Image'></div>";
}
} else {
echo "No images found";
}
$db->close();
?>
</section>
<?php include('footer.php'); ?>
</body>
</html>