Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php sql查询会更改url,但不会';不改变数据_Php_Sql_Max - Fatal编程技术网

php sql查询会更改url,但不会';不改变数据

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

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

这就是我的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>     


您希望查询中的
其中id=$next
。不是你所拥有的

为什么有两个mysql查询

"Select * FROM people WHERE `id` = $next"

您应该选择
其中id=$next
。您显示的图像似乎少于87个,因此限制条款的行为与您的预期不符。

因此,我必须做什么来代替此操作?