Search code examples
phpmysqlbindparam

php bind_param for limit


I have problem with binding values to mysql query in php.

$this->conn->prepare("SELECT * FROM tablename LIMIT ? , ? ");
$pageStart = 11; 
$pageEnd = 20 ;
$stmt->bind_param("ii" , $pageStart , $pageEnd );
$stmt->execute();

This is returning 20 rows. Any help?


Solution

  • This is correct behaviour.

    From the documentation:

    ...
    [LIMIT {[offset,] row_count | row_count OFFSET offset}]
    ...
    

    the number after the comma is rowcount.

    If you want 10 records, just tell that:

    SELECT * FROM tablename LIMIT 11 , 10;