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;
}
搜索
最新推荐文章于 2023-11-18 13:41:41 发布