yourphp搜索代码
HTML代码
<form method="GET" action="index.php?"> //指向地址
<input type="hidden" id="" name="m" value="Search"/>
<select id="module" name="module" style="display:none"> //重点:获取模型
<option selected="selected" value="Product">产品模型
</option>
</select>
<div class="input01">
<input type="text" name="keyword" id="" class="input-text" value="" /> //关键词
</div><div class="button01">
<input type="image" src="/yt/Yourphp/Tpl/Home/new/Public/images/button01.jpg" />
</div>
</form>
php代码 \Yourphp\Lib\Action\Home\SearchAction.class.php
<?php
/**
*
* SearchAction.class.php (前台搜索功能)
*
* @package YOURPHP
* @author liuxun QQ:147613338 <admin@yourphp.cn>
* @copyright Copyright (c) 2008-2011 (http://www.yourphp.cn)
* @license http://www.yourphp.cn/license.txt
* @version YourPHP企业网站管理系统 v2.1 2011-03-01 yourphp.cn $
*/
if(!defined("Yourphp")) exit("Access Denied");
class SearchAction extends BaseAction
{ function _initialize()
{
parent::_initialize();
} public function index()
{
//搜索
$_REQUEST['id'] = $catid = intval($_REQUEST['id']);
$p= max(intval($_REQUEST[C('VAR_PAGE')]),);
$_REQUEST['keyword'] = $keyword = get_safe_replace($_REQUEST['keyword']);
$_REQUEST['module'] = $module = get_safe_replace($_REQUEST['module']);
$module = $module ? $module : 'Article' ;
$this->assign($_REQUEST);
$this->assign('bcid',);
$where = " status=1 "; if(APP_LANG){
$lang = LANG_NAME;
$langid= LANG_ID;
$where .=" and lang= $langid";
$this->assign('lang',$lang);
$this->assign('langid',$langid);
} if($catid){
$cat = $this->categorys[$catid];
$bcid = explode(",",$cat['arrparentid']);
$bcid = $bcid[];
if($bcid == '') $bcid=intval($catid);
if(empty($module))$module=$cat['module'];
unset($cat['id']);
$this->assign($cat);
$cat['id']=$catid;
$this->assign('catid',$catid);
$this->assign('bcid',$bcid); if($cat['child']){
$where .= " and catid in(".$cat['arrchildid'].")";
}else{
$where .= " and catid=".$catid;
}
}
$seo_title = $cat['title'] ? $cat['title'] : $cat['catname'];
$this->assign ('seo_title',$keyword.' '.$seo_title);
$this->assign ('seo_keywords',$keyword.$cat['keywords']);
$this->assign ('seo_description',$keyword.$cat['description']); if($keyword){ if(strstr($keyword,'or')){
$keydo = ' or ';
$keyword_arr= explode('or',$keyword);
}elseif(strstr($keyword,' ')){
$keydo = ' AND ';
$keyword_arr= explode(' ',$keyword);
} if(count($keyword_arr)>){
foreach($keyword_arr as $key =>$keywordz){
$keyword_arr[$key] = ' title like "%'.trim($keywordz).'%" ';
}
$where .= ' AND ('.implode($keydo,$keyword_arr).')';
}else{
$where .= ' AND title like "%'.$keyword.'%" ';
}
}
$this->dao= M($module);
$count = $this->dao->where($where)->count();
$this->assign('count',$count); if($count){
import ( "@.ORG.Page" );
$listRows = !empty($cat['pagesize']) ? $cat['pagesize'] : C('PAGE_LISTROWS');
$page = new Page ( $count, $listRows );
$_REQUEST['p'] = '{$page}';
$page->urlrule = URL('Home-Search/index',$_REQUEST);
$pages = $page->show();
$field = $this->module[$cat['moduleid']]['listfields'];
$field = $field ? $field : 'id,catid,userid,url,username,title,title_style,keywords,description,thumb,createtime,hits';
$list = $this->dao->field($field)->where($where)->order('id desc')->limit($page->firstRow . ',' . $page->listRows)->select();
$this->assign('pages',$pages);
$this->assign('list',$list);
} $this->display(); }
}
?>
yourphp搜索代码的更多相关文章
- 完善dedecms站内搜索代码,为搜索结果添加第*页
自那些平凡而伟大的程序猿开发了内容管理系统(cms),为了让看客们更快地找到自己感兴趣的内容,他们不断完善站内搜索代码,形成了一个小型的站内搜索引擎.可能有些网站模板设计师没考虑到seo的问题,很多站 ...
- 一分钟加入google站内搜索代码
一分钟加入google站内搜索代码| 一分钟加入google站内搜索代码|只有7行最精简.网上有很多 google 站内搜索代码,但是出于某些目的,很多都加入了多余的代码,从seo的角度来讲,是很不优 ...
- [转载]《Delphi 版 everything、光速搜索代码》 关于获取文件全路径 GetFullFileName 函数的优化
Delphi 版 everything.光速搜索代码>,文章中关于获取文件全路径的函数:GetFullFileName,有一个地方值得优化. 就是有多个文件,它们可能属于同一个目录. 譬如 Sy ...
- Html 小插件5 百度搜索代码2
网页添加百度搜索框代码大全 ★ 用法:在下面选择合适的样式,复制代码到网页中相应位置粘贴即可. ★ 样式一(200×30)代码: <iframe id="baiduframe" ...
- 自适应大邻域搜索代码系列之(1) - 使用ALNS代码框架求解TSP问题
前言 上次出了邻域搜索的各种概念科普,尤其是LNS和ALNS的具体过程更是描述得一清二楚.不知道你萌都懂了吗?小编相信大家早就get到啦.不过有个别不愿意透露姓名的热心网友表示上次没有代码,遂不过瘾啊 ...
- python kd树 搜索 代码
kd树就是一种对k维空间中的实例点进行存储以便对其进行快速检索的树形数据结构,可以运用在k近邻法中,实现快速k近邻搜索.构造kd树相当于不断地用垂直于坐标轴的超平面将k维空间切分,依次选择坐标轴对空间 ...
- [转载]Delphi 版 everything、光速搜索代码
近日没啥事情,研究了一下 everything.光速搜索原理.花了一个礼拜时间,终于搞定. 废话不多说,直接上代码: unit uMFTSearchFile; { dbyoung@sina.com 2 ...
- stream,做减法,优化搜索代码。
做一个搜索,三个输入条件,求这个条件的交集.起初我的思路是按照操作的流程,一步步的来做这三个筛选. let searchResults = []; //step1 根据id搜索,得到一个子集. if ...
- [php] 使用IDE的正则搜索代码
([^a-zA-Z_=$0-9/\[\>])('|"|,)?(\s*)store_banner(\s*)('|"|,)?([^a-zA-Z_=$0-9\/\(\]:]) 用在 ...
随机推荐
- [转]Java使用commons-dbcp2.0
原文地址:http://blog.csdn.net/jiutianhe/article/details/39670817 dbcp 是 apache 上的一个 java 连接池项目,也是 tomcat ...
- 51nod 1163贪心
用优先队列来贪心,是一个很好地想法.优先队列在很多时候可以维护最值,同时可以考虑到一些其他情况. http://www.51nod.com/onlineJudge/questionCode.html# ...
- 一起学HTML基础-CSS样式表-基本概念、分类、选择器
一.基本概念: CSS (Cascading Style Sheets)层叠样式表,是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言. ...
- iOS的网络环境判断
网络环境的判断有两种方式 1.Reachability 2.AFNetWorking中 AFNetworkReachabilityManager Reachability步骤 (1)导入Reachab ...
- Leetcode 270. Closest Binary Search Tree Value
Given a non-empty binary search tree and a target value, find the value in the BST that is closest t ...
- Node.js使用Mongoose包操作MongoDB数据库
1. 安装Mongoose npm install mongoose 2. 使用 2.1 创建连接 var mongoose = require('mongoose'); mongoose.conne ...
- HDU 4223 Dynamic Programming?(最小连续子序列和的绝对值O(NlogN))
传送门 Description Dynamic Programming, short for DP, is the favorite of iSea. It is a method for solvi ...
- Linux下,使用Git管理 dotfiles(配置文件)
1.管理你的 dotfiles 作为一个计算机深度使用者,并且长期使用 Linux 作为主要操作系统,折腾各种功能强大的软件是常有的事儿.这些软件有它们各自的配置文件,通常以 . 开头,因此有人管它们 ...
- Linux系统被入侵后处理经历
服务器托管在外地机房. 突然,频繁收到一组服务器ping监控不可达邮件,赶紧登陆zabbix监控系统查看流量状况. 可见流量已经达到了800M左右,肯定不正常,马上尝试SSH登陆系统,不幸的事,这种情 ...
- 关于vs生成app错误提示,提醒Execution failed for task ':transformClassesWithDexForDebug'.
昨天将vs和android SDK更新之后生成app之后发现app生成出错,报错如下: FAILURE: Build failed with an exception. * What went wro ...