搜索

public function ajax_sear()
    {
         $k_word = empty($_POST['k_word']) ? '' : $data = $_POST['k_word'];//关键字
         $year = empty($_POST['year']) ? '' : $data = $_POST['year'];//时间
         $catid = empty($_POST['catid']) ? '' : $data = $_POST['catid'];
         //过滤
        $k_word = safe_replace(trim($k_word));
        $k_word = new_html_special_chars(strip_tags($k_word));
        $k_word = str_replace('%', '', $k_word);   
         // 处理时间
        date_default_timezone_set('Asia/Shanghai'); 
        $year = strtotime($year);
        $next_year = $year + 31536000;
        $sql_time = "a.inputtime >" .$year. " and a.inputtime <" .$next_year;
        //条件
        $from = "from v9_download as a , v9_download_data as b where a.id=b.id and a.catid='$catid'";
        $limit = 2; 
        //判断搜索条件
        if(!empty($k_word))
        {
            $from .= "and a.title like'%$k_word%'";
        }
        if(!empty($year))
        {
            $from .= 'and '.$sql_time;
        }
        //查询出来的个数
        // $sql_count = "select count(*) as count ". $from;
        // $data_count = $this->db->fetch_array($this->db->query($sql_count));
        // $count = $data_count[0][count];
        //执行搜索  
        $sql = "select a.title, a.url, a.inputtime,b.content,b.downfiles ".$from /*. "limit $limit"*/;
        $result = $this->db->query($sql);
        $result = $this->db->fetch_array($result);
        $str .= "<ul class='downloadList'>";
        foreach($result as $v){
             $down_url = string2array($v['downfiles']);
            $str .='<li>
                        <h3 class="clearfix">
                            <p class="tit">•'.$v[title].'</p>
                            <a href="'.$down_url[0][fileurl].'" class="btn">下载</a>
                        </h3>
                        <div class="downTxt">'.$v[content].'</div>
                    </li>';
        }
        $str .= '</ul>';
        echo $str;
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值