$tablename="titles,content ";
$pageSize=30;
$goPage=$goPage;
$selcetFields="id,title,post_time,img_name ";
$sqlConditions="and status='Y' and id=title_id ";
if (trim($keywords)!="") {
if (trim($kind)=="title"){$sqlConditions .= " and title like '%$keywords%' ";}
else if (trim($kind)=="fromto"){$sqlConditions .= " and fromto like '%$keywords%' ";}
else if (trim($kind)=="content"){$sqlConditions .= " and (title like '%$keywords%' or content like '%$keywords%') ";}
}
if (trim($sqlConditions)!="") {$sqlConditions=substr($sqlConditions,3);}
$sqlOrders=" order by id desc";
if ($keywords != "" && $kind != "") {
$url="$PHP_SELF?$oriVARS&keywords=".$keywords."&kind=".$kind ;
}else {
$url="$PHP_SELF?$oriVARS";
}
//===
//返回第一条记录位置、总行数、当前页码和总页码
list($firstRow,$totleRows,$currentPage,$totalPages)=
divpage($tablename,$sqlConditions,$totleRows,$pageSize,$goPage);
//建立并执行查询语句
$strQuery="select $selcetFields from $tablename ";
if (trim($sqlConditions)!=""){$strQuery.="where $sqlConditions ";}
if (trim($sqlOrders)!=""){$strQuery.=" $sqlOrders";}
$strQuery .=" limit $firstRow, $pageSize ";
//echo $strQuery;
$db->query($strQuery);
//===取出数据===
while ($db->next_record()) {
list($id,$title,$post_time,$img_name)=$db->Record;
$show_time=substr($post_time,0,10); // $show_time=date("m-d",$post_time);
if (trim($keywords)!=""){$title=str_replace($keywords,"".$keywords."",$title);}
if($img_name<>"")
{ echo "· $title [$show_time]
";
}
else {echo "· $title [$show_time]
";
}
}
?>