根据SQL查询的条件格式突出显示表行

时间:2019-02-28 16:38:31

标签: php html sql

已编辑 我有一个SQL查询,我想用红色突出显示突出显示表行,以便如果transaction_date = 0000-00-00整个行都用红色突出显示。这是代码片段。 transaction_date显示了参加特定培训课程的日期,如果未参加该课程,则将返回注册日期。任何帮助将不胜感激。谢谢。

  $sql = "SELECT DATE_FORMAT(date_fluids, '%m/%d/%Y ') AS transaction_date, first_name, last_name, supervisor_group, trade, t_id, c_id, department_number, date_fluids, fluids_refresh, fluid_period, employee_type
        FROM peopleinfo WHERE
        (last_name LIKE '%$value1%' )
        and 
        (trade LIKE '%$value2%')
        and
        (t_id LIKE '%$value3%')
        and
        (c_id LIKE '%$value4%')
        and
        (department_number LIKE '%$value5%')
        and
        (date_fluids LIKE '%$value6%')
        and
        (date_lock LIKE '%$value7%')
        and
        (date_confine LIKE '%$value8%')
        and
        (date_fall LIKE '%$value9%')
        and
        (supervisor_group LIKE '%$value10%')
        AND
        (employee_type='1')
        ORDER BY last_name ASC";






$query = mysqli_query($conn, $sql);

$row = (mysqli_fetch_array($query));    







if (!$query) {
    die ('SQL Error: ' . mysqli_error($conn));
}

while ($row = mysqli_fetch_array($query))
{

        if ($row['transaction_date'] == 0000-00-00){
    echo '<tr class="highlight">';
    echo         '<td >' . $row['first_name']. '</td>';
    echo         '<td >' . $row['last_name']. '</td>';
    echo         '<td >' . $row['supervisor_group']. '</td>';
   echo      '<td >' . $row['trade']. '</td>';
   echo      '<td >' . $row['t_id']. '</td>';
echo         '<td >' . $row['c_id']. '</td>';
   echo      '<td >' . $row['department_number']. '</td>';
    echo         '<td >' . $row['transaction_date']. '</td>';
    echo         '<td >'. $row['fluid_period']. '</td>';
echo '</tr>';
} else {
   echo '<tr >';
    echo         '<td >' . $row['first_name']. '</td>';
    echo         '<td >' . $row['last_name']. '</td>';
    echo         '<td >' . $row['supervisor_group']. '</td>';
   echo      '<td >' . $row['trade']. '</td>';
   echo      '<td >' . $row['t_id']. '</td>';
echo         '<td >' . $row['c_id']. '</td>';
   echo      '<td >' . $row['department_number']. '</td>';
    echo         '<td >' . $row['transaction_date']. '</td>';
    echo         '<td >'. $row['fluid_period']. '</td>';
echo '</tr>';

}  
}
mysqli_free_result($query);
mysqli_close($conn);
?>
 </tbody>
</table>

1 个答案:

答案 0 :(得分:0)

我会做:

ipcMain.on('aaa', (e, filename) => { 
    // exec(pythonfile params);
    e.sender('bbb', response);
})

,然后使用css突出显示它。