Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何将if语句添加到我的搜索表单-Wordpress/Woocommerce_Php_Html_Wordpress - Fatal编程技术网

Php 如何将if语句添加到我的搜索表单-Wordpress/Woocommerce

Php 如何将if语句添加到我的搜索表单-Wordpress/Woocommerce,php,html,wordpress,Php,Html,Wordpress,使用内置Wordpress搜索表单: <?php if ( function_exists( 'woocommerce_product_search' ) ) { echo woocommerce_product_search( array( 'limit' => 40 ) ); } ?> <div class="col-lg-4 col-lg-offset-4"> <div class="input-group"> <

使用内置Wordpress搜索表单:

<?php
  if ( function_exists( 'woocommerce_product_search' ) ) {
    echo woocommerce_product_search( array( 'limit' => 40 ) );
  }
?>

<div class="col-lg-4 col-lg-offset-4">
  <div class="input-group">
    <input type='textbox' maxlength="8" id="item-search" name="s" class="form-control form-inline" value="<?php the_search_query();?>" placeholder="Enter your postcode e.g. SW1Y 4LG"/>
    <span class="input-group-btn">
      <button class="item-search-btn">search</button>
    </span>
  </div>
</div>

</form>


将var输入文本更改为$input\u text,然后重试
不幸的是,这是错误的。
对的
还有一些。

您可以使用$input text作为var not input text,然后打印第一个$input text,这样您就知道将输出什么。用else语句更好地理解好的,我明白你的意思。非常感谢。你有密码的答案吗@莫莉,请检查下面的代码绝对精彩!谢谢你,莫莉
<?php get_search_form(); ?>
<div id="postcode-no" class="col-lg-4 col-lg-offset-4">
    Unfortunately this is incorrect.
</div>
<?php if (input-text=='SW12') { ?>
    <div id="postcode-no" class="col-lg-4 col-lg-offset-4">
        Unfortunately this is incorrect.
    </div>
<?php } else if (input-text=='SW15'){ ?>
    <div id="postcode-no2" class="col-lg-4 col-lg-offset-4">
        Correct.
    </div>
<?php } ?>
Chaneg the var input-text to $input_text than try 
<?php if ($input_text=='SW12'): ?>
<div id="postcode-no" class="col-lg-4 col-lg-offset-4">
    Unfortunately this is incorrect.
</div>
<?php elseif ($input_text=='SW15'): ?>
<div id="postcode-no2" class="col-lg-4 col-lg-offset-4">
    Correct.
</div>
<?php else: ?>
<div id="postcode-no2" class="col-lg-4 col-lg-offset-4">
    Some Else.
</div>
<?php endif; ?>