PHP query MySQL multiple condition judgment output display
Background:
Query each field value output from MySQL and display the criteria field values in red font.
Conditions:
1.syntime is less than the current week before the words show red.
2.A field is "None", the display is red.
3.B field is "None", the display is red.
Figure A database structure:
Figure Two database field values:
My Code: (I only met the first condition, the other two conditions do not know how to write)
$sql = "Select Username, OnOff, intime, syntime, device, a,b,person,dtime from Cdmobile ORDER by username desc";
$rst = mysql_query ($sql);
while ($row =mysql_fetch_array ($rst)) {
$nowtime =strtotime (' +7 Day ');
$syntime =strtotime ($row [' syntime ']);
if ($nowtime >= $syntime) {
Echo ' {$row [' username ']}{$row [' onoff ']}{$row [' Intime ']}{$row [' syntime ']}{$row [' Device ']}
>{$row [' A ']}{$row [' B ']}{$row [' Person ']}{$row [' Dtime ']} ';
}
Else
echo {$row [' username ']}{$row [' onoff ']}{$row [' Intime ']}{$row [' syntime ']}{$row [' Device ']}{] $row [' A ']}{$row [' B ']}{] $row [' Person ']}{$row [' Dtime ']} ';
}
Please help your aunt to improve the code. To be able to satisfy three conditions at the same time, and the correct output, the red display where the red. The following are the current results:
------Solution--------------------
echo "{$row [' username ']}{$row [' onoff ']}{$row [' Intime ']}";
if ($nowtime >= $syntime)
echo "{$row [' Syntime ']}";
Else
echo "{$row [' Syntime ']}";
echo "{$row [' Device ']}";
if ($row [' A ']== "none")
echo "{$row [' a ']}";
Else
echo "{$row [' a ']}";
if ($row [' b '] = "none")
echo "{$row [' B ']}";
Else
echo "{$row [' B ']}";
echo "{$row [' person ']}{$row [' Dtime ']}";
Correct the