php sql查询会更改url,但不会';不改变数据
我正在尝试为我的数据库创建一个“下一步按钮”,这样我就可以一次查看一个图像。然而,我现在拥有它的方式只是改变了url,而不是实际的图像,无论url是什么,它都会粘贴到具有最高id的图像上(87)。我该如何解决这个问题 这就是我的db的样子php sql查询会更改url,但不会';不改变数据,php,sql,max,Php,Sql,Max,我正在尝试为我的数据库创建一个“下一步按钮”,这样我就可以一次查看一个图像。然而,我现在拥有它的方式只是改变了url,而不是实际的图像,无论url是什么,它都会粘贴到具有最高id的图像上(87)。我该如何解决这个问题 这就是我的db的样子 <?php require("includes/conn.php"); if (isset($_GET["imagecount"])) $next = (int)$_GET["imagecount"]; //int is for sql inject
<?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>
您希望查询中的
其中id=$next
。不是你所拥有的
为什么有两个mysql查询
"Select * FROM people WHERE `id` = $next"
您应该选择
其中id=$next
。您显示的图像似乎少于87个,因此限制条款的行为与您的预期不符。因此,我必须做什么来代替此操作?