当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Dynamic LIMIT in MySQL prepared statement

问题描述:

Here is the piece of code:

 $stmt1 = $conn->prepare("SELECT * FROM image_table WHERE username=:mname && status=1 ORDER BY number DESC LIMIT :min, 5");

$stmt1->bindParam(':mname', $mname);

$stmt1->bindParam(':min', $minimum, PDO::PARAM_INT);

$stmt1->execute();

This code is inside a loop that increases $minimum by 5 each time it runs starting at 0, to display all of a members images in rows of 5 columns. When I set :min manually it works but I think because it changes with each iteration, it won't display anything. Does bindParam not work with a dynamic variable?

分享给朋友:
您可能感兴趣的文章:
随机阅读: