2017-09-04 42 views
0

我写这些代码用于在我的项目中搜索功能。 如果用户输入正确的邮政编码,它会显示一个表单,如果邮政编码错误,它会显示一些我在其他条件下编写的邮件。 但是默认情况下,当用户第一次进入页面时显示else消息。 如果用户输入错误的邮政编码,我想显示(我在其他条件下写入的邮件)消息?任何建议。系统默认打印其他消息php

<small>Enter your zipcode to book our service</small> 
    <?php if($this->isAllowedZipcode=="Matched"){?> 
    <div class="row"> 
    </div> 
    <?php } ?> 
    <?php } else 
    { ?> 
     <div class="row"> 
      <div class="col-sm-12 col-xs-12"> 
       <p>Sorry but our services are not available in your area. We are working hard to cover as much area as we can. Thank you for using the system.</p> 
        <?php } ?> 
+0

你的代码似乎不完整,如果您使用的条件不明确,请重新检查你的代码 –

+0

''结束你的'if'。 '<?php} else'继续__some other'if'__ –

回答

0

您的代码似乎是不正确/不完整的,但根据您的要求,你可以做到这一点如下:

<small>Enter your zipcode to book our service</small> 
    <?php if($this->isAllowedZipcode=="Matched"){ ?> 
     <div class="row"> 
       //ZIPCODE MATCHED 
     </div> 
    <?php } else { ?> 
     <div class="row"> 
      <div class="col-sm-12 col-xs-12"> 
       <p>Sorry but our services are not available in your area. We are working hard to cover as much area as we can. Thank you for using the system.</p> 
      </div> 
     </div> 
    <?php } ?> 
+0

我试过但它不能正常工作 –

+0

这只是一个想法来解决你的问题,你将不得不在“如果”的条件下工作,你应该了解如果其他条件在php –

-1

您可以使用elseif条件时,你可以测试邮政编码是设置,不仅else

<small>Enter your zipcode to book our service</small> 
    <?php if($this->isAllowedZipcode=="Matched"){?> 
    <div class="row"> 
    </div> 
    <?php } elseif (isset($inputZipCode)) 
    { ?> 
     <div class="row"> 
      <div class="col-sm-12 col-xs-12"> 
       <p>Sorry but our services are not available in your area. We are working hard to cover as much area as we can. Thank you for using the system.</p> 
        <?php } ?> 
+0

中工作你有相同的错误和主代码m8 – Sand

+0

你做的和OP一样的错误,这个额外大括号“}”的作用是什么? –

+0

好吧,我纠正它,对不起。 – Rinos