gpt4 book ai didi

php - 如何检查mysql在while循环中获取的行是否相同

转载 作者:行者123 更新时间:2023-11-29 19:10:50 24 4
gpt4 key购买 nike

如何检查 while 循环的结果行值是否相同,我需要在所有结果的状态完成时进行更新...

        $result = $db->query("SELECT * FROM fy_working_staf_cstm WHERE task_id_c='".$t_id."'");
while($row = $db->fetchRow($result)){
++$tas;
$staff_id=$row['id_c'];
$result1 = $db->query("SELECT `status` FROM `fy_working_staf` WHERE id='".$staff_id."' AND `status`='Completed'");
$staf = $db->fetchByAssoc($result1);
$status = $staf['status'];
if($stat=='Completed')
{
++$tas1;
//$comple_staus='Closed_Closed';
}
}
if(($tas == $tas1) && ($tas1 !=0) )
{
$q = $db->query("UPDATE `tasks` SET `status`='Completed' WHERE id='".$t_id."' ");
$st = $db->fetchByAssoc($q);
}

最佳答案

相反,我可以在其中使用中断条件:

  while($row = $db->fetchRow($result)){
$staff_id=$row['id_c'];
$result1 = $db->query("SELECT `status` FROM `fy_working_staf` WHERE id='".$staff_id."' AND `status`='Completed'");
$staf = $db->fetchByAssoc($result1);
$status = $staf['status'];
if($stat!='Completed')
{
$comple_staus='Closed_Closed';
break;// will exit the loop when the row is not same

}
}

关于php - 如何检查mysql在while循环中获取的行是否相同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43093471/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com