我有一个已经设置了一些图像的数据库,我想让 url 在用户点击下一个时显示每个查询的 ID。用户应该能够共享 URL 并将其粘贴到他们的浏览器中,该 url 应该从查询中提取该唯一 ID。我遇到的问题是每次我粘贴一个网址时,我都会得到一个随机图像,而不是 ID 中的图像。我在这里不知所措,我不确定该怎么做:(这是我到目前为止的代码。
<?php
if (isset($_GET['id'])) {
include("PHP/db.php");
echo $where = $_GET["id"];
echo $query = "SELECT * FROM images WHERE ID =" . $where;
$result = mysqli_query($dbc, $query);
$row = mysqli_fetch_array($result);
$ID = $row['ID'];
$title = $row['name'];
$image = "<img height=500 width=600 src=http://www.goupics.com/img/" . $row['name'] . " >";
}
if($_GET['next4']) {
echo 'HELLO THIS IS THE NEXT IF METHOD';
include("PHP/db.php");
$query = "SELECT * FROM images ORDER BY RAND() LIMIT 1";
$result = mysqli_query($dbc, $query);
$row = mysqli_fetch_array($result);
$ID = $row['ID'];
$title = $row['name'];
$image = "<img height=500 width=600 src=http://www.goupics.com/img/" . $row['name'] . " >";
}
?>
<body>
</div>
<div id="title"> <?php echo $title ?> </div>
<div id="mainpic">
<?php echo $image ?>
</div>
<div id="prevnext">
<div id="next">
<a href="?id=<?php echo $ID ?>" name="name4" >Next</a>
</div>
<div id="prev">
<a href="?id=<?php echo $ID ?>">Previous</a>
</div>
</div>