我正在尝试为我的数据库创建一个“下一步按钮”,这样我就可以一次查看一张图片。然而,我现在拥有它的方式只改变了url,而不是实际上的图像check it out here.,它坚持具有最高id的图像(87),无论url是什么。我该如何解决这个问题?
这是我的db的样子。

<?php
require("includes/conn.php");
if (isset($_GET["imagecount"]))
$next = (int)$_GET["imagecount"]; //int is for sql injection
else
$next = 0;
$result = mysql_query("select * from people order by id desc limit $next, 1") or die(mysql_error());
?>
<?php
$result = mysql_query("select * from people order by id desc limit 0, 1 ") or die ("haznot DB: " . mysql_error());
while ($row = mysql_fetch_assoc($result))
{
echo "<img src=\"images/" . $row['filename'] . "\" alt=\"\" /><br />";
}
?>
<a href="images.php?imagecount=<?php echo $next+1; ?>">Next</a> 发布于 2012-12-07 07:11:09
您希望在查询中使用WHERE id = $next。而不是你所拥有的。
为什么你有两个mysql查询...
"Select * FROM people WHERE `id` = $next"发布于 2012-12-07 07:24:35
您应该选择WHERE id=$next。您当前的图像似乎不到87个,因此limit子句的行为不会像您预期的那样。
https://stackoverflow.com/questions/13754243
复制相似问题