<body>
<h1> helloo </h1>
<div class="gallery">
<?php
// Include database configuration file
require 'dbConfig.php';
// Retrieve images from the database
$query = $DB->query("SELECT * FROM /phpgallery/images WHERE status = 1 ORDER BY uploaded_date DESC");
if($query->num_rows > 0){
while($row = $query->fetch_assoc()){
$imageThumbURL = 'images/'.$row["file_name"];
$imageURL = 'images/'.$row["file_name"];
?>
<a href="<?php echo $imageURL; ?>" data-fancybox="gallery" data-caption="<?php echo $row["title"]; ?>" >
<img src="<?php echo $imageThumbURL; ?>" alt="" />
</a>
<?php }
} ?>
</div>
</body>
<body>
<h1> helloo </h1>
<div class="gallery">
<?php
// Include database configuration file
require 'dbConfig.php';
// Retrieve images from the database
$query = $DB->query("SELECT * FROM /phpgallery/images WHERE status = 1 ORDER BY uploaded_date DESC");
if($query->num_rows > 0){
while($row = $query->fetch_assoc()){
$imageThumbURL = 'images/'.$row["file_name"];
$imageURL = 'images/'.$row["file_name"];
?>
<a href="<?php echo $imageURL; ?>" data-fancybox="gallery" data-caption="<?php echo $row["title"]; ?>" >
<img src="<?php echo $imageThumbURL; ?>" alt="" />
</a>
<?php }
} ?>
</div>
</body>
这两个文件在同一个文件夹中,但数据库在另一个文件夹中。
E:\Xampp\htdocs\phpgallery\images <- 存储数据库的图像。E:\Xampp\htdocs\dynamicImageGallery <- 我从哪里运行代码。
至尊宝的传说