到达表的最后一条记录后,如何继续执行else语句?

zwghvu4y  于 2021-07-26  发布在  Java
关注(0)|答案(1)|浏览(330)

我有一张旗子桌
我要做的是:在表查询到达最后一条记录之后,它将执行else语句

while($row = $result->fetch_array()){
if (++$counter == $numResults) {
    $sql1 = "UPDATE QueueP1 SET STATUS = '1' WHERE STATUS ='0' LIMIT 1";
    $result1 = $conn->query($sql1);
    echo "Now processing No ".$row['now']."<Br>";       
    }
 else{
    echo "<p class='lead'><em>No more transactions left.</em></p>";

} }

l7mqbcuq

l7mqbcuq1#

在while循环中提到查询是没有用的。我想你想要的是这个

$sql1 = "UPDATE QueueP1 SET STATUS = '1' WHERE STATUS ='0' LIMIT 1";
$result1 = $conn->query($sql1);
while($row = $result->fetch_array()){
if (++$counter == $numResults) {  
 echo "Now processing No ".$row['now']."<Br>";       
    }
}
echo "<p class='lead'><em>No more transactions left.</em></p>";

相关问题