简体   繁体   English

php if和else if从SQL值声明

[英]php if and else if statement from a sql value

I have a query like so: 我有这样的查询:

if ($auto_hold = sql::value("select a.code, a.primcode, b.secondary_auto_hold from ev.do.nt_dg_li() a
                         left outer join eve.do.nce_data b on a.seccode = b.CODE_
                         where primcode like 'INSM%%' and secondary_auto_hold = 1 and code='$patient_id'"))

if my variable matches that query than i want to echo an alert if it doesn't than it should do nothing. 如果我的变量与该查询匹配,则我想回显警报(如果不匹配),则不执行任何操作。

easy question but i'm drawing blanks atm. 一个简单的问题,但我正在绘制空白atm。 any help would be greatly appreciated. 任何帮助将不胜感激。 Thank you. 谢谢。

I've tried various assignment operators ie. 我试过各种赋值运算符,即。 ==, === but nothing. ==,===但什么也没有。

I'm sure i could probably drop the variable as well and just say if(sql::value etc) 我确定我也可能会删除该变量,只是说if(sql :: value等)

I figured it out: 我想到了:

if ($patient_id == $auto_hold) echo "<div class='patient_alert_red'>Auto hold on deductible for this patient.</div>"; 

My answer is as follows: 我的回答如下:

if ($patient_id == $auto_hold) echo "<div class='patient_alert_red'>Auto hold on deductible for this patient.</div>"; 

I used the == / Equal operator to verify they're the same. 我使用== /等于运算符来验证它们是否相同。

More here: 更多内容:

http://www.w3schools.com/php/php_operators.asp http://www.w3schools.com/php/php_operators.asp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM