Php query mysql multi-condition judgment output display
Background:
Query the output of each field value from mysql and display the field values that meet the condition in red according to the condition.
Condition:
1. If syntime is less than the previous week, the syntime is red.
2. If field A is "NONE", it is red.
3. If the field B is "NONE", it is red.
Figure 1 database structure:
Figure 2 database field values:
My code: (I only met the first condition, but I don't know how to write the other two conditions)
$ 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 me complete the code. If three conditions are met at the same time and the output is correct, the red area is displayed. 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