// search.php v 2.1.0.1 2001/4/28 justlau Exp $
include("search_header.htm");
require "./global.php3";
?>
##############
php_track_vars;
#################################################函数的开始
###############################################执行查询的函数,并分页显示
function searchdisplay()
{
require "config.php3";
global $intGotoPage,$DB_site,$searchKey,$keywords,$starttime,$endtime,$magazineid,$totalnum,$totalpages;
$searchKey = ($searchKey) ? $searchKey:"brief";
$fromtime = ($starttime) ? $starttime." 00:00:00" : "";
$totime = ($endtime) ? $endtime." 00:00:00" : "";
$searchtime = "时间段:从 ";
$searchtime .= ($starttime) ? $starttime : " 不限开始时间 到 ";
$searchtime .= ($endtime) ? $endtime : " 不限结束时间";
# $magazineid = ($magazineid) ? $magazineid : 1;
$intLineNum=30;
if($intGotoPage <= 0) $intGotoPage=1;
$start = ($intGotoPage-1)*$intLineNum;
if(trim($keywords))
{
switch($searchKey)
{
case "title":
$needfield = " a.magazineid,a.magpath,a.isspath,a.brief,a.title,a.createdate,a.id ";
$sql = " from bt_column_article a where ( a.title like '%".$keywords."%') ";
$sql .= ($magazineid) ? " and a.magazineid='$magazineid'" : "";
$sql .= ($fromtime)? " and a.createdate>='$fromtime' " : "" ;
$sql .= ($totime)? " and a.createdate<='$totime' " : "" ;
$sql .= " order by a.id desc";
$msg = "提交的条件:标题包含'$keywords'";
break;
case "brief":
$needfield = " a.magazineid,a.magpath,a.isspath,a.brief,a.title,a.createdate,a.id ";
$sql = " from bt_column_article a where ( a.brief like '%".$keywords."%' or a.title like '%".$keywords."%') ";
$sql .= ($magazineid) ? " and a.magazineid='$magazineid'" : "";
$sql .= ($fromtime)? " and a.createdate>='$fromtime' " : "" ;
$sql .= ($totime)? " and a.createdate<='$totime' " : "" ;
$sql .= " order by a.id desc";
$msg = "提交的条件:智能包含'$keywords'";
break;
case "words":
$needfield = " a.magazineid, a.magpath,a.isspath,a.brief,a.title,a.createdate,a.id ";
$sql = " from bt_column_article a,bt_article b where b.id=a.articleid and b.keywords like '%".$keywords."%' ";
$sql .= ($magazineid) ? " and a.magazineid='$magazineid'" : "";
$sql .= ($fromtime)? " and a.createdate>='$fromtime' " : "" ;
$sql .= ($totime)? " and a.createdate<='$totime' " : "" ;
$sql .= " order by a.id desc";
$msg = "提交的条件:关键字包含'$keywords'";
break;
case "author":
$needfield = " a.magazineid, a.magpath,a.isspath,a.brief,a.title,a.createdate,a.id ";
$sql = " from bt_column_article a,bt_article b where b.id=a.articleid and b.author like '%".$keywords."%' ";
$sql .= ($magazineid) ? " and a.magazineid='$magazineid'" : "";
$sql .= ($fromtime)? " and a.createdate>='$fromtime' " : "" ;
$sql .= ($totime)? " and a.createdate<='$totime' " : "" ;
$sql .= " order by a.id desc";
$msg = "提交的条件:作者包含'$keywords'";
break;
case "all":
if(trim($keywords))
{
$needfield = " a.magazineid, a.magpath,a.isspath,a.brief,a.title,a.createdate,a.id ";
$sql = " from bt_column_article a,bt_article b where ( (b.id=a.articleid and ( b.author like '%".$keywords."%' or b.keywords like '%".$keywords."%' ) ) or a.title like '%".$keywords."%' or a.brief like '%".$keywords."%' ) ";
$sql .= ($magazineid) ? " and magazineid='$magazineid'" : "";
$sql .= ($fromtime)? " and a.createdate>='$fromtime' " : "" ;
$sql .= ($totime)? " and a.createdate<='$totime' " : "" ;
$sql .= " order by a.id desc";
}
/* else
{
$sql = "select magazineid, magpath,isspath,brief,title,createdate,id from bt_column_article where id>0 ";
$sql .= ($magazineid) ? " and magazineid='$magazineid'" : "";
$sql .= ($fromtime)? " and createdate>='$fromtime' " : "" ;
$sql .= ($totime)? " and createdate<='$totime' " : "" ;
$sql .= " order by id desc";
}*/
$msg = "提交的条件:所有包含'$keywords'";
break;
}
if(!$totalnum)
{
$sql2 = "select distinct count(a.id) as tid ".$sql;
$totalnums = $DB_site->query_first($sql2);
$totalnum = $totalnums[tid];
$totalpages = intval($totalnum/$intLineNum);
if( !($totalnum%$intLineNum) ) $totalpages = $totalpages+1;
if($totalpages<=0) $totalpages=1;
}
// else
// {
// $sql = " select DISTINCT ".$needfield.$sql;
// }
$sqlinfo = "select DISTINCT ".$needfield.$sql." limit $start,$intLineNum";
// print $sqlinfo;
$result = $DB_site->query($sqlinfo);
$rowsNum = $DB_site->num_rows($result);
/*
if($intGotoPage){
$intOffset=($intGotoPage-1)*$intLineNum;
}
$intShowLine=$intLineNum;
$intLineFrom=$intOffset+1;
$intLineTo=$intLineFrom+$intShowLine -1;
if($rowsNum<$intLineTo) {
$intLineTo=$rowsNum;
$intShowLine=$rowsNum-$intLineFrom+1;
}*/
?>
--'.$totalpages.' --'.$intLineNum; ?> $condition = "searchKey=$searchKey"; $condition .= "&keywords=$keywords"; $condition .= "&starttime=$starttime"; $condition .= "&endtime=$endtime"; $condition .= "&magazineid=$magazineid"; $intWhileNum=10; $intSelfLine=$intGotoPage; #本页 $intStartPage=(($intSelfLine-1)-(($intSelfLine-1)%$intWhileNum)); $intEndPage=$intStartPage+$intWhileNum-1; if($totalpages<$intEndPage){ $intEndPage=$totalpages-1; $intWhileNum=$intEndPage-$intStartPage+1; } $return="
|