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搜索代码的更多相关文章

  1. 完善dedecms站内搜索代码,为搜索结果添加第*页

    自那些平凡而伟大的程序猿开发了内容管理系统(cms),为了让看客们更快地找到自己感兴趣的内容,他们不断完善站内搜索代码,形成了一个小型的站内搜索引擎.可能有些网站模板设计师没考虑到seo的问题,很多站 ...

  2. 一分钟加入google站内搜索代码

    一分钟加入google站内搜索代码| 一分钟加入google站内搜索代码|只有7行最精简.网上有很多 google 站内搜索代码,但是出于某些目的,很多都加入了多余的代码,从seo的角度来讲,是很不优 ...

  3. [转载]《Delphi 版 everything、光速搜索代码》 关于获取文件全路径 GetFullFileName 函数的优化

    Delphi 版 everything.光速搜索代码>,文章中关于获取文件全路径的函数:GetFullFileName,有一个地方值得优化. 就是有多个文件,它们可能属于同一个目录. 譬如 Sy ...

  4. Html 小插件5 百度搜索代码2

    网页添加百度搜索框代码大全 ★ 用法:在下面选择合适的样式,复制代码到网页中相应位置粘贴即可. ★ 样式一(200×30)代码: <iframe id="baiduframe" ...

  5. 自适应大邻域搜索代码系列之(1) - 使用ALNS代码框架求解TSP问题

    前言 上次出了邻域搜索的各种概念科普,尤其是LNS和ALNS的具体过程更是描述得一清二楚.不知道你萌都懂了吗?小编相信大家早就get到啦.不过有个别不愿意透露姓名的热心网友表示上次没有代码,遂不过瘾啊 ...

  6. python kd树 搜索 代码

    kd树就是一种对k维空间中的实例点进行存储以便对其进行快速检索的树形数据结构,可以运用在k近邻法中,实现快速k近邻搜索.构造kd树相当于不断地用垂直于坐标轴的超平面将k维空间切分,依次选择坐标轴对空间 ...

  7. [转载]Delphi 版 everything、光速搜索代码

    近日没啥事情,研究了一下 everything.光速搜索原理.花了一个礼拜时间,终于搞定. 废话不多说,直接上代码: unit uMFTSearchFile; { dbyoung@sina.com 2 ...

  8. stream,做减法,优化搜索代码。

    做一个搜索,三个输入条件,求这个条件的交集.起初我的思路是按照操作的流程,一步步的来做这三个筛选. let searchResults = []; //step1 根据id搜索,得到一个子集. if ...

  9. [php] 使用IDE的正则搜索代码

    ([^a-zA-Z_=$0-9/\[\>])('|"|,)?(\s*)store_banner(\s*)('|"|,)?([^a-zA-Z_=$0-9\/\(\]:]) 用在 ...

随机推荐

  1. VS 2013 未找到与约束contractname Microsoft.VisualStudio.Utilities.IContentTypeRegistryService...匹配的导出[vs故障]【转】

    未找到与约束 contractname Microsoft.VisualStudio.Utilities.IContentTypeRegistryService RequiredTypeIdentit ...

  2. U盘常见问题汇总

    优盘常见问题,持续更新.大家有什么问题可以留言,一起解决,谢谢. 1.优盘中的文件全部变成快捷方式解决办法 打开优盘,查找updat.vbs文件脚本,此文件脚本为病毒脚本,若找不到文件脚本则开启隐藏文 ...

  3. 国外有哪些比较好的IT社区

    作者:匿名用户链接:https://www.zhihu.com/question/35373320/answer/114468522来源:知乎著作权归作者所有,转载请联系作者获得授权. Github ...

  4. iframe与主框架跨域相互访问方法【转】

    转自:http://blog.csdn.net/fdipzone/article/details/17619673 1.同域相互访问 假设A.html 与 b.html domain都是localho ...

  5. XML和JSON的对比

    简介: 客户端和服务器之间进行数据交互时,服务器往往会返回给客户端一定格式的数据.一般而言,服务器返回给客户端的数据为JSON或者XML文档格式的数据(文件下载除外).下面就针对于这两种数据格式分别介 ...

  6. 【caffe】epoch,[batch_size],iteration的含义

    @tags caffe 概念 一个epoch表示"大层面上的一次迭代",也就是指,(假定是训练阶段)处理完所有训练图片,叫一个epoch 但是每次训练图片可能特别多,内存/显存塞不 ...

  7. HA模式手动切换namenode状态

    查看状态 hdfs haadmin -getServiceState nn1 有时候通过网页访问两个namenode的http-address,看到默认的主namenode状态变成了standy,这时 ...

  8. 【poj1177】 Picture

    http://poj.org/problem?id=1177 (题目链接) 题意 求矩形周长并. Solution 转自:http://www.cnblogs.com/Booble/archive/2 ...

  9. 深入了解asp.net框架。生命周期以及事件处理机制

    刚接触asp.net框架觉得很好奇.他的快速开发是怎么实现的.控件的状态又是怎么保持的.我们都知道http是无状态的.而且网上很多人都说使用asp.net框架使用服务器框架是非常慢的. 带着这些疑问我 ...

  10. 降低磁盘IO使Oracle性能优化(转)

    文章转自:http://blog.chinaunix.net/uid-26813519-id-3207996.html 硬件方面虽然只占Oracle性能优化的一个方面(另一方面是软件),但是仍不可忽视 ...