dongqiao9015 2014-12-22 16:31
浏览 26

PHP - 用于比较/验证文本的IF语句

Fairly new to PHP - But I come from a fairly fluent Classic ASP VBScript background.

PHP 5.5 (?) - Somewhere in there. MySQL db.

  • Have a MySQL table with a column [sale_status]
  • [sale_status] has values of "E" or "P" ("Expired" or "Pending", respectively)

  • I am looping through the table with PHP, and it displays all the values correctly ("E" or "P")

  • I am trying to do an "IF Statement" to do something when the value is "E" and something other thing for anything else.

  • My "IF Statement reads like...":

    $salestatus = {{sale_status}}
    
    if ($salestatus == "E") {
         echo ("YES");
    } ELSE {
         echo ("NO");
    }
    
  • For this, I get NO for everything (E and P).

  • I have tried === and strcmp and strcasecmp, but get the same thing.

  • I KNOW the values from {{sale_status}} are correct, because I can just echo that variable through the loop, and it display all the correct values.

  • For some reason, though, it will not distinguish E from P, or whatever.

  • In Classic ASP, it would be as simple as (if {sale_status} = "E", then ...) - and it works.

  • I know PHP has its own nuances, so that is what I am trying to learn.

Help is appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥16 Qphython 用xlrd读取excel报错
    • ¥15 单片机学习顺序问题!!
    • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
    • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
    • ¥15 相敏解调 matlab
    • ¥15 求lingo代码和思路
    • ¥15 公交车和无人机协同运输
    • ¥15 stm32代码移植没反应
    • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
    • ¥100 连续两帧图像高速减法