[前台调用]添加搜索功能DYCMS
1.搜索表单:
<form action="/article/search.php" method="get">
<input type="text" id="keyword" name="keyword" placeholder="标题、关键词、内容" />
<input type="submit" value="搜索...
1.搜索表单:
<form action="/article/search.php" method="get">
<input type="text" id="keyword" name="keyword" placeholder="标题、关键词、内容" />
<input type="submit" value="搜索"/>
</form>
2.复制article下面的list.php、list_config.php重命名为search.php、search_config.php
3.修改search_config.php
删除查询分类信息的代码,查询条件部分代码改为:
//查询条件:关键词
$keyword=$_GET['keyword'];
if($keyword<>""){
$ifkeyword=" and (title like '%".$keyword."%' or content like '%".$keyword."%')";
}
查询语句中只使用$ifkeyword这个条件
4.修改search.php
require "list_config.php";
改为:
require "search_config.php";
显示栏目名称的地方改为“搜索结果”
分页链接中的参数只使用$keyword
上一篇:[前台调用]查询指定分类的子分类
下一篇:[插件]仿QQ商城幻灯代码
我要评论