简体   繁体   中英

MySqli Query result row

I want use one column value in mysqli query but I am not able to find way of use it. My query is like this

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



    }

I want get value of column automatic_number and want use it as LIMIT like this

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

I am trying from half hour but not able to find way of it. Let me know if any expert can help me. Thanks

query:

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

execution:

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

mistake

if($row['automatic'] ==on)

correct: if($row['automatic'] =='on')

if you want to assign value of $result['automatic'] then

$number=$result['automatic'];

this may be he reason you are not getting limit

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

if you want to use value the atomatic_number in the limit where the atomatic_number is the table of the tbl_settings then just change

$number=$result['automatic'];

to

$number=$result['automatic_number'];

then

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

I hope this is what you are looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM