mysqli查询结果行

4zcjmb1e  于 2021-06-25  发布在  Mysql
关注(0)|答案(3)|浏览(374)

我想在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");

    }

我想得到列的值,并希望使用它作为限制像这样

$sql = mysqli_query($mysqli,"SELECT _quid FROM tbl_quotes where qu_status=0 ORDER BY _quid ASC LIMIT $number");

我试了半个小时,但找不到办法。如果有Maven能帮我,请告诉我。谢谢

8yoxcaq7

8yoxcaq71#

如果您想在atomatic\u数是tbl\u设置表的限制中使用atomatic\u数,那么只需更改

$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");

我希望这就是你要找的。

c8ib6hqw

c8ib6hqw2#

查询:

$sqlquery = "SELECT _quid FROM tbl_quotes where qu_status=0 ORDER BY _quid ASC LIMIT " .$number;

执行:

$sql = mysqli_query($mysqli, $sqlquery);
wbgh16ku

wbgh16ku3#

错误

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");

相关问题