SQL 添加 LIMIT 关键字后不起作用

SQL not working when I add the LIMIT keyword to it

无法让我的 SQL LIMIT 工作:

$sql = mysqli_query($conn, "SELECT url, code, count FROM zipit WHERE uid='".$uid."' LIMIT '".$this_page_first_result."','".$results_per_page."'");

试试这个:

$sql = mysqli_query($conn, "SELECT url, code, count FROM zipit WHERE uid='".$uid."' LIMIT ".$this_page_first_result.", ".$results_per_page);

您编写查询的方式转化为:

SELECT url , 
       code , 
       count 
FROM   zipit 
WHERE  uid='uid1234' 
LIMIT  '123','50'

您的 LIMIT 子句的单引号无效。 . .

你应该使用的是:

$sql = mysqli_query($conn,"SELECT url,code,count 
                           FROM zipit 
                           WHERE uid='".$uid."' 
                           LIMIT ".$this_page_first_result.",".$results_per_page);

LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants, with these exceptions:

Within prepared statements, LIMIT parameters can be specified using ? placeholder markers.

Within stored programs, LIMIT parameters can be specified using integer-valued routine parameters or local variables.

With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1)

$sql = mysqli_query($conn, "SELECT url, code, count FROM zipit WHERE uid=$uid LIMIT $this_page_first_result,$results_per_page");