как отобразить данные (разделенные на 2 по имени столбца таблицы типа bool) в php - PullRequest
0 голосов
/ 05 июля 2018

В моем классе php я получаю результат запроса и хотел бы отобразить данные в 2 столбцах на основе значения из таблицы db (активной или неактивной). Я хотел бы иметь что-то вроде этого:

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;
    }
}
...