php while循环中的对齐问题

卡鲁皮亚RK

在这里,我没有任何编码相关的问题。我正在尝试从多个数据库表中获取详细信息。获取结果工作正常。但是对齐是我的问题。

在此处输入图片说明

您可以看到一张图像。在该图像中,凭证状态列运行正常。但是,最后两行始终是另外两列(房间状态和用餐状态值)。如何正确地调整这些(房间和用餐状态)值(如“凭单状态”列)?我希望你能理解我的问题...

      <?php
        echo "<table width=1090 border=1 style=\"border: #ddd;\" align=center cellspacing=4 cellpadding=10>";
        echo "<tr class=thvoucher>";
        echo "<th width=30>Voucher Number</th>";
        echo "<th width=80>Reference Number</th>";
        echo "<th width=200>Guest Name</th>";
        echo "<th width=150>Voucher Status</th>";
        echo "<th width=150>Room Status</th>";
        echo "<th width=150>Meal Status</th>";
        echo "</tr>";
        for($i = $start; $i < $end; $i++) 
        {
            if ($i == $total_results) 
            {
                break;
            }
            while($row = $stmt->fetch())
            {
               $voucherid = $row['VoucherID'];
           $ref = $row['VoucherReference'];
           $gname = $row['GuestName'];
           $vstatus = $row['ActiveStatus'];
           echo "<tr class=voucherstyle" . $cls . ">";
           echo "<td>$voucherid</td>";    **// FIRST TD**
           echo "<td>$ref</td>";    **// SECOND TD**
           echo "<td>$gname</td>";     **// THIRD TD**

                      if( $vstatus != 'empty' )       **// FOURTH TD**
        {
            if( $vstatus == 'Y' )
            {
                echo "<td class=green >Active</td>";
            }
            else if( $vstatus == 'N' )
            {
                echo "<td class=red >Inactive</td>";
            }
        }
        else
            {
                echo "<td><form method=post onsubmit=\"return mstatusvalidate(this)\"; action='voucherstatus_update.php?id_meal= $voucherid '><select name=mealstatus><option value=empty></option><option value=active>Active</option><option value=inactive>Inactive</option></select><input type=submit class=update_status title=\"Update $gname voucher status\" value=Update></form></td>";
            }
            }

            while($r_row = $r_stmt->fetch())
            {
                $rstatus = $r_row['ActiveStatus'];

                        // same like above if else statement      **// FIFTH TD**
            }       

            while($m_row = $m_stmt->fetch())
            {
                $mstatus = $m_row['ActiveStatus']; 

                        // same like above if else statement  **// SIXTH TD**       
            }
echo "</tr>";
            }
            echo "</table>";
            ?>
卡鲁皮亚RK

我在使用条件时让它工作while(($row = $stmt->fetch()) && ($r_row = $r_stmt->fetch()) && ($m_row = $m_stmt->fetch()))在我使用三个单独的while循环之前现在,我还有其他想法。我尝试过,现在它的工作和对齐方式也很完美。在我没有发布我的if else语句代码之前。所以,每个人都以为我只用了3吨。抱歉让每个人感到困惑...我在下面发布了正确的编码。

     <?php
        echo "<table width=1090 border=1 style=\"border: #ddd;\" align=center cellspacing=4 cellpadding=10>";
        echo "<tr class=thvoucher>";
        echo "<th width=30>Voucher Number</th>";
        echo "<th width=80>Reference Number</th>";
        echo "<th width=200>Guest Name</th>";
        echo "<th width=150>Voucher Status</th>";
        echo "<th width=150>Room Status</th>";
        echo "<th width=150>Meal Status</th>";
        echo "</tr>";
        for($i = $start; $i < $end; $i++) 
        {
            if ($i == $total_results) 
            {
                break;
            }
            while(($row = $stmt->fetch()) && ($r_row = $r_stmt->fetch()) && ($m_row = $m_stmt->fetch()))
            {
                $voucherid = $row['VoucherID'];
                $ref = $row['VoucherReference'];
                $gname = $row['GuestName'];
                $vstatus = $row['ActiveStatus'];
                echo "<tr class=voucherstyle" . $cls . ">";
                echo "<td>$voucherid</td>";       **1st TD**
                echo "<td>$ref</td>";      **2nd TD**
                echo "<td>$gname</td>";      **3rd TD**
                if( $vstatus != 'empty' )      **4th TD**
                {
                    if( $vstatus == 'Y' )
                    {
                        echo "<td class=green >Active</td>";
                    }
                    else if( $vstatus == 'N' )
                    {
                        echo "<td class=red >Inactive</td>";
                    }
                }
                else
                    {
                        echo "<td><form method=post onsubmit=\"return mstatusvalidate(this)\"; action='voucherstatus_update.php?id= $voucherid '><select name=mealstatus><option value=empty></option><option value=active>Active</option><option value=inactive>Inactive</option></select><input type=submit class=update_status title=\"Update $gname voucher status\" value=Update></form></td>";
                    }

                $rstatus = $r_row['ActiveStatus'];
                // if else statement      **5th TD**

                $mstatus = $m_row['ActiveStatus'];
                // if else statement      **6th TD**
                echo "</tr>";
            }
        }
        echo "</table>";
        ?>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章