I have made a photo gallery, which shows photos from MySQLi database, but when I click on the link on each photo, it must go to a single page that only shows that photo.
Index.php
$query = mysqli_query($conn, "SELECT * FROM images");
while($row = mysqli_fetch_array($query)) {
$id = $row['id'];
$image = $row['image'];
echo "<td><a href='single.php?id=$id'><img src='$image'></a></td>";
}
Single.php
$id = $row['id'];
$query = mysqli_query($conn, "SELECT * FROM images WHERE id='$id'");
<?php
while($row = mysqli_fetch_array($query)) {
$image = $row['image'];
echo "<img src='$image'>";
}
Single.php将第一行更改为
$id = intval($_GET['id']);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.