//获取查询结果
$type = $_POST['type']?$_POST['type']:$_COOKIE['type'];
$keyword = trim($_POST['keyword'])?trim($_POST['keyword']):$_COOKIE['keyword'];
setcookie('type',$type);
setcookie('keyword',$keyword);
$this->assign('keyword',$keyword);
$this->assign('type',$type);
//搜索新闻
if($type==1){
$news = D('News');
$count=$news->where("ischecked=1 and subject like '%$keyword%'")->count($data);
import("@.ORG.Page");
$p=new page($count,12);
$list=$news->where("ischecked=1 and subject like '%$keyword%'")->order('id desc')->limit($p->firstRow.','.$p->listRows)->findAll();
$i = 0;
foreach($list as $vo){
$content = $vo['subject'];
$list[$i++]['subject']=[color=red]str_ireplace($keyword,"<font color='#FF0000'>".$keyword."</font>",$content);[/color] //关键字红色字体
}
$page=$p->show();
if ($list!==false) {
$this->assign('page',$page);
$this->assign('list',$list);
$this->assign('count',$count);
}
}
$type = $_POST['type']?$_POST['type']:$_COOKIE['type'];
$keyword = trim($_POST['keyword'])?trim($_POST['keyword']):$_COOKIE['keyword'];
setcookie('type',$type);
setcookie('keyword',$keyword);
$this->assign('keyword',$keyword);
$this->assign('type',$type);
//搜索新闻
if($type==1){
$news = D('News');
$count=$news->where("ischecked=1 and subject like '%$keyword%'")->count($data);
import("@.ORG.Page");
$p=new page($count,12);
$list=$news->where("ischecked=1 and subject like '%$keyword%'")->order('id desc')->limit($p->firstRow.','.$p->listRows)->findAll();
$i = 0;
foreach($list as $vo){
$content = $vo['subject'];
$list[$i++]['subject']=[color=red]str_ireplace($keyword,"<font color='#FF0000'>".$keyword."</font>",$content);[/color] //关键字红色字体
}
$page=$p->show();
if ($list!==false) {
$this->assign('page',$page);
$this->assign('list',$list);
$this->assign('count',$count);
}
}