[英]I am trying to pass a variable from php into a sql function for a LIMIT value
I am attempting to add multiple pages to display data on my website, rather than one long list.我正在尝试添加多个页面以在我的网站上显示数据,而不是一个长列表。 I am doing this by using LIMIT from sql.
我是通过使用 sql 中的 LIMIT 来做到这一点的。 How can I pass my variable from php into the sql statement?
如何将我的变量从 php 传递到 sql 语句中? Below is my code
下面是我的代码
$sql = 'SELECT fldDateLogged, fldUserEarnings '; $sql = 'SELECT fldDateLogged, fldUserEarnings ';
$sql .= 'FROM tblDataTracked '; $sql .= '从 tblDataTracked ';
$sql .= 'WHERE fldEmail = ? $sql .= 'WHERE fldEmail = ? ';
';
$sql .= 'LIMIT VariableHere, 5 '; $sql .= 'LIMIT VariableHere, 5 ';
Is it a possibility that this can work?这有可能奏效吗? if so how can I pass my php variable into the VariableHere spot?
如果是这样,我如何将我的 php 变量传递到 VariableHere 位置? Thanks!
谢谢!
is it possible.是否可以。 you can use quote or even bracket to do that.
你可以使用引号甚至括号来做到这一点。 for example
SELECT * from tmp_subtitle where token='{$token}'
or SELECT * from tmp_subtitle where token="'".$token."'"
例如
SELECT * from tmp_subtitle where token='{$token}'
或SELECT * from tmp_subtitle where token="'".$token."'"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.