Home  >  Article  >  Backend Development  >  应用Php或是wordpress程序做一个搜索框

应用Php或是wordpress程序做一个搜索框

WBOY
WBOYOriginal
2016-06-13 12:49:151041browse

使用Php或是wordpress程序做一个搜索框
想做一个多功能搜索框,不知道怎么实现,用的是wordpress程序
大致效果如图:
怎么弄都只执行最后一个框的关键词搜索,求各位大大赐教呀。

WordPress PHP 搜索
------解决方案--------------------
1.一定要有哦
2.把SQL输出一下看下拼接是否正确
------解决方案--------------------
把各种 参数 提交 到服务器, 服务器程序拼接一下 SQL 语句,就OK 了
------解决方案--------------------
提交的时候,获取参数看看
------解决方案--------------------
引用:
引用:1.一定要有哦
2.把SQL输出一下看下拼接是否正确

           
"/>


一个就够了吧。其他的通过后台获取变量后再拼接SQL
------解决方案--------------------
<form id="search" target="_blank" action="<?php bloginfo('url'); ?>"/><br />
<input class="pinpai" type="text" name="pinpai" id="pinpai" value="品牌" onFocus="this.value='';" onBlur="if(this.value==''){this.value='品牌';}"/><br />
<input class="chexi" type="text" name="chexi" id="chexi" value="车系" onFocus="this.value='';" onBlur="if(this.value==''){this.value='车系';}"/><br />
<input class="jiage" type="text" name="jiage" id="jiage" value="价格范围" onFocus="this.value='';" onBlur="if(this.value==''){this.value='价格范围';}"/><br />
<input class="guanjianci" type="text" name="keyword" id="keyword" value="关键词" onFocus="this.value='';" onBlur="if(this.value==''){this.value='关键词';}"/><br />
    <button class="search01" type="submit">搜索</button><br />
</form>	

把name和id都唯一,后台用$_POST['name']来取值
------解决方案--------------------
$_POST['name']就是后台接收数据时候用的啊
name是你前面input框的name值
用这个试试吧
if(isset($_POST['name'])){
   echo $_POST['name'];
}


发送表单的方式分为post和get两种,在里这样设定

详细的可以去w3school看看
------解决方案--------------------
sql就能搞定了 $_post['文本框框名字']
------解决方案--------------------
如果所有input 的name都是"s",那post过去只能得到最后的那个值,也就是关键词的。需要将每个input的name都改成不一样,然后后台使用$_POST['input的name']取得对应的值
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn