简体   繁体   English

我试图将一个变量从 php 传递到一个 LIMIT 值的 sql 函数中

[英]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.

相关问题 我应该如何使用 PHP 和 SQL 将数据库中的值存储为 php 中的变量? - How am I supposed to store a value from my database as a variable in php using PHP and SQL? 使用PHP中的表格,我试图返回取决于输入的SQL值的SQL值? - Using a form in PHP, I am trying to return an SQL value dependant on an entered SQL value? 试图将php变量传递给javascript函数 - Trying to pass a php variable to javascript function 为什么我无法在PHP中传递变量 - Why I am unable to pass a variable in PHP 我正在尝试将一些 PHP 变量和 Javascript 变量传递到 Javascript window.location.href 中的 url - I am trying to pass some PHP variables and Javascript variable into url in Javascript window.location.href 如何将值从JavaScript函数传递给PHP变量? - How to pass value from JavaScript function to PHP variable? 我正在尝试向 mysql 插入一个 php 变量,但是它会自动插入 0 而不是变量的值 - I am trying to insert a php variable to mysql but, it automatically inserts 0 instead of the value of the variable 我试图改变div的背景图像使用PHP和jquery.php变量不获取值 - I am trying to change a background image of div using php and jquery.php variable not getting the value 尝试将变量从JQuery传递给PHP - Trying to pass a variable from JQuery to PHP 如何将 PHP 变量从一个函数传递到另一个函数? - How do I pass a PHP variable from one function to another?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM