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, it is red. 2. if field A is none, it will be red. 3. if the field B is none, it is red. Database structure: database field values: my code :( I only met the first condition, but I do not know how to write the other two conditions) $ SQL & nbs 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.
Database structure:
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