Php query mysql multi-condition judgment output display

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.