如何在php中显示数据(按bool类型的表列名划分为2)

如何在php中显示数据(按bool类型的表列名划分为2),php,multiple-columns,Php,Multiple Columns,在我的php类中,我从查询中得到一个结果,并希望根据db表中的值(active或inactive)在两列上显示数据。我想要这样的东西: active inactive supplier name a supplier name d supplier name b supplier name e supplier name c supplier name f 这是我的代码: while ($sensor_row = $result_of_query-&g

在我的php类中,我从查询中得到一个结果,并希望根据db表中的值(active或inactive)在两列上显示数据。我想要这样的东西:

active             inactive
supplier name a    supplier name d
supplier name b    supplier name e
supplier name c    supplier name f
这是我的代码:

while ($sensor_row = $result_of_query->fetch_assoc()) {
    if ($sensor_row['active'] == 0) {
        $status = 's_on';

        $thisSensor = '<div class="statusTitle">Active Suppliers</div>';
        $thisSensor .= '<div class="row clearfix sensor ' . $sensor_row['id'] . '">';
        $thisSensor .= '    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">';
        $thisSensor .= '        <div class="card">';
        $thisSensor .= '        <div class="body ' . $status . '">&nbsp;</div>';
        $thisSensor .= '        </div>';
        $thisSensor .= '    </div>';
        $thisSensor .= '</div>';

        echo $thisSensor;
    } else if ($sensor_row['active'] == 1) {
        $status = 's_on';

        $thisSensor = '<div class="statusTitle">Inactive Suppliers</div>';
        $thisSensor .= '<div class="row clearfix sensor ' . $sensor_row['id'] . '">';
        $thisSensor .= '    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">';
        $thisSensor .= '        <div class="card">';
        $thisSensor .= '        <div class="body ' . $status . '">&nbsp;</div>';
        $thisSensor .= '        </div>';
        $thisSensor .= '    </div>';
        $thisSensor .= '</div>';

        echo $thisSensor;
    }
}
while($sensor\u row=$result\u of\u query->fetch\u assoc()){
如果($sensor_row['active']==0){
$status='s_on';
$thisSensor=‘活跃供应商’;
$thisSensor.='';
$thisSensor.='';
$thisSensor.='';
$thisSensor.='';
$thisSensor.='';
$thisSensor.='';
$thisSensor.='';
回波传感器;
}否则如果($sensor_row['active']==1){
$status='s_on';
$thisSensor=‘非活跃供应商’;
$thisSensor.='';
$thisSensor.='';
$thisSensor.='';
$thisSensor.='';
$thisSensor.='';
$thisSensor.='';
$thisSensor.='';
回波传感器;
}
}

您必须解释什么东西不符合预期,以便我们能够帮助您。您可以使用SQL中的active和inactive获取数据。