Home > Backend Development > PHP Tutorial > 下列语句该如何设置多条件查询

下列语句该如何设置多条件查询

WBOY
Release: 2016-06-23 13:47:10
Original
982 people have browsed it

$result_style = $row['result'] == '红色'  ? ' style="color:red"' : '';

这条代码只能在result是红色的时候,sytle才能显示为红色。
如何让result是红色的时候,并且$row['type']==‘小明’时,style显示为红色呢? 


回复讨论(解决方案)

$result_style = $row['result'] == '红色'  && $row['type']==‘小明’ ? ' style="color:red"' : '';

$result_style = $row['result'] == '红色' && $row['type']=='小明'  ? ' style="color:red"' : '';
Copy after login

唉,我傻逼了,用的and,忘了用&&。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template