如果该行为空,该怎么办呢?

假设名称行为空

echo '<td>' . $row['name'] . '</td>';


因此,如果名称行为空白,则将显示echo '<td>' . $row['companyname'] . '</td>';

请帮我如何解决这个问题
谢谢

        echo "<tr>";
        echo '<td>' . $row['buildingname'] . '</td>';
        echo '<td>' . $row['area'] . '</td>';
        echo '<td>' . $row['city'] . '</td>';
        echo '<td>' . $row['flatno'] . '</td>';
        echo '<td>' . $row['name'] . '</td>';
        echo '<td>' . $row['mobileno'] . '</td>';
        echo '<td>' . $row['agreementdates'] . '</td>';
        echo '<td>' . $row['agreementdatee'] . '</td>';
        echo "</tr>";

最佳答案

尝试

if(empty( $row['name'])){
  $tbl = '<td>' . $row['companyname'] . '</td>';
}else{
   $tbl = '<td>' . $row['name'] . '</td>';
}
echo $tbl;

关于php - 如果此行为空,则将显示另一行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20343524/

10-10 05:26