我想在mysqli查询中使用一个列值,但我无法找到使用方法。我的查询是这样的
$result = mysqli_query($mysqli,"SELECT * FROM tbl_settings");
while($row = $result->fetch_assoc()){
if($row['automatic'] ==on){
$number= "$result['automatic']";
echo $number;
$sql = mysqli_query($mysqli,"SELECT _quid FROM tbl_quotes where qu_status=0 ORDER BY _quid ASC LIMIT 5");
while($result = mysqli_fetch_array($sql)){
$qu_time = getDatetimeNow();
$results = mysqli_query($mysqli,"UPDATE tbl_quotes SET qu_status=1,qu_favorite=0, qu_time='$qu_time' where _quid=".$result['_quid']." ORDER BY _quid ASC");
}
我想获取列 automatic_number 的值,并希望将其用作 LIMIT ,就像这样
$sql = mysqli_query($mysqli,"SELECT _quid FROM tbl_quotes where qu_status=0 ORDER BY _quid ASC LIMIT $number");
我正在尝试半小时但却无法找到方法。如果有专家可以帮助我,请告诉我。感谢
答案 0 :(得分:0)
查询:
$sqlquery = "SELECT _quid FROM tbl_quotes where qu_status=0 ORDER BY _quid ASC LIMIT " .$number;
执行:
$sql = mysqli_query($mysqli, $sqlquery);
答案 1 :(得分:0)
错误
if($row['automatic'] ==on)
正确的:
if($row['automatic'] =='on')
如果您想指定$result['automatic']
的值,那么
$number=$result['automatic'];
这可能是他没有得到限制的原因
在这里$sql = mysqli_query($mysqli,"SELECT _quid FROM tbl_quotes where qu_status=0 ORDER BY _quid ASC LIMIT 6");
答案 2 :(得分:0)
如果你想在atomatic_number是tbl_settings表中使用atomatic_number值,那么只需更改
$number=$result['automatic'];
到
$number=$result['automatic_number'];
然后
$sql = mysqli_query($mysqli,"SELECT _quid FROM tbl_quotes where qu_status=0 ORDER BY _quid ASC LIMIT $number");
我希望这就是你要找的东西。