PHP If语句中的检查数限制

时间:2014-03-13 23:13:35

标签: php html

我是PHP和HTML的新手我还有其他几个带有两个或三个OR的IF语句,它们看起来效果很好。

我要检查的是' NULL'空白'空间'或文字'无'。如果我发现其中任何一个,我想做select语句。如果没有匹配,我想使用从数据库中取出的$ AT_Med_1_1数据。

如下所示的IF声明,看不到我的工作。即使$ AT_Med_1_1是其他内容,它总是会进入SELECT语句。

       if ($AT_Med_1_1 == '' or $AT_Med_1_1 == NULL or $AT_Med_1_1 == ' ' or    $AT_Med_1_1 = 'None') {
 <select name="AT_Med_1_2">
        <option value="None">None</option>
        <option value="Oral_Zofran">Oral Zofran</option>
        <option value="IV_Zofran">IV_Zofran</option>
        <option value="Oxygen">Oxygen</option>
        <option value="Ibuprofen">Ibuprofen</option>
        <option value="Aetaminothen">Aetaminothen</option>
        <option value="Upinephrne">Upinephrne</option>
        <option value="Xopenex">Xopenex</option>
        <option value="Albuterol">Albuterol</option>
        <option value="Valium">Valium</option>
        <option value="Magnesiunsulphate">Magnesiunsulphate</option>
        <option value="Diphenhyamine">Diphenhyamine</option>
        <option value="Ketorolac">Ketorolac</option>
        <option value="Promethazion">Promethazion</option>
        <option value="Oral_Fluids_Soup">Oral Fluids Soup</option>
        <option value="Oral_Fluids_Electrolyte">Oral Fluids Electrolyte</option>
        <option value="Oral_Fluids_Water">Oral Fluids Water</option>        
      </select>
      <?php
      }  else {
//          echo 'Showing $AT_';
          echo $AT_Med_1_2;
          echo nl2br("\n");
      }
?>

如果我将IF语句更改为其他几个,如果它似乎正常工作

if ($AT_Med_1_1 == '')      
{
   goto test1;
 } else if ($AT_Med_1_1 == NULL)
{
   goto test1;
} else if ($AT_Med_1_1 == ' ')
{
   goto test1;
 } else if ($AT_Med_1_1 == 'None')
{
   goto test1;
 }
    goto test;  

    test1:         
              ?>
          <select name="AT_Med_1_1">
            <option value="None">None</option>
            <option value="Oral_Zofran">Oral Zofran</option>
            <option value="IV_Zofran">IV_Zofran</option>
            <option value="Oxygen">Oxygen</option>
            <option value="Ibuprofen">Ibuprofen</option>
            <option value="Aetaminothen">Aetaminothen</option>
            <option value="Upinephrne">Upinephrne</option>
            <option value="Xopenex">Xopenex</option>
            <option value="Albuterol">Albuterol</option>
            <option value="Valium">Valium</option>
            <option value="Magnesiunsulphate">Magnesiunsulphate</option>
            <option value="Diphenhyamine">Diphenhyamine</option>
            <option value="Ketorolac">Ketorolac</option>
            <option value="Promethazion">Promethazion</option>
            <option value="Oral_Fluids_Soup">Oral Fluids Soup</option>
            <option value="Oral_Fluids_Electrolyte">Oral Fluids Electrolyte</option>
            <option value="Oral_Fluids_Water">Oral Fluids Water</option>        
          </select>
              <?php
              goto endtest;

    test: 
              echo $AT_Med_1_1;
              echo nl2br("\n");
    endtest:  

1 个答案:

答案 0 :(得分:3)

if (... or $AT_Med_1_1 = 'None') {

对于最后一个条件,您不小心写了=而不是==