只想显示数据库中的 2 个值而不是显示 6 个值

问题描述 投票:0回答:0

在下面的代码中,我已经显示了 wsodb.alot 数据库中 upflag 的值。我想做的是我只想显示 upflag 的值是重新测试还是返工,它会显示值是 RT 表示重新测试,RW 表示返工。现在,它显示了 upflag 的所有值,我只想显示重新测试和返工的值,如 RT 和 RW。

$upflagone = array("retesting","reworking");
                $sql_LSput3 = "Select * from wsodb.alot where lotid='".$v["eventLotid"]."'";
                $result_LSput3 = mysqli_query($conn,$sql_LSput3); 
                $cnt_LSput3=mysqli_num_rows($result_LSput3);
            
            
            if ($cnt_LSput3 > 0) {
            $row_LSput3 = mysqli_fetch_array($result_LSput3);
            $upflag = $row_LSput3['upflag'];
            
            if ($upflag == 'retesting') {
                $upflag = 'RT';
            }else if ($upflag == 'reworking') {
                $upflag = 'RW';
            }
            
            if (in_array($upflag, $upflagone)) {
                $upflag = substr($upflag, -3); // extract last 3 characters of owner
                echo "upflag: " . $upflag;
            } else {
            }
        } else {
            echo "No records found.";
        }

另一种方法是我尝试如下。但是当我更改为该代码时,数据库中有一个名为“测试”的值,并将重新测试和测试的 RT 显示为 RT。

sql_LSput3 = "Select * from wsodb.alot where lotid='".$v["eventLotid"]."'";
                $result_LSput3 = mysqli_query($conn,$sql_LSput3); 
                $cnt_LSput3=mysqli_num_rows($result_LSput3);
                
            
            if ($cnt_LSput3 > 0) {
                $row_LSput3 = mysqli_fetch_array($result_LSput3);
                $upflag = $row_LSput3['upflag'];

                if ($upflag == 'retesting') {
                    $upflag = 'RT';
                    echo "upflag: " . $upflag;
                    $upflagtwo = "&nbsp;<font class=ft8 color=red><b>".$upflag."</b></font>";
                } else {
                    echo "No records found.";
                }
            }
php mysql phpmyadmin
© www.soinside.com 2019 - 2024. All rights reserved.