PHP query MySQL multi-condition judgment output display
Background:
Query each field value output from MySQL and match the criteria field value with a red font according to the criteria.
Conditions:
1.syntime is less than the current week before the time of the display red.
If the 2.A field is "None", it shows red.
If the 3.B field is "None", it shows red.
Figure A database structure:
Figure two database each field value:
My Code: (I only met the first condition, the remaining 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 aunt to help improve the code. To be able to meet three conditions at the same time, and can output correctly, the red color of the display shows 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 ']}";
Corrected under
http://www.bkjia.com/PHPjc/820406.html www.bkjia.com true http://www.bkjia.com/PHPjc/820406.html techarticle PHP query MySQL multi-conditional judgment output display background: From MySQL query each field value output and according to criteria in red font display satisfies the criteria field value. Condition: 1.syntime less than current before ...