<?php
session_start();
include_once("../config/templateConfig.inc.php");
include_once("../config/databaseConfig.inc.php");
$templateMain   = new SmartTemplate('Search.html');
$templateMenu   = new SmartTemplate('menu.html');
$templateTop    = new SmartTemplate('top.html');
$templateBottom = new SmartTemplate('copyRight.html');
/*
输出头部
*/
$templateTop->output();
/*
输出菜单
*/
$menu="电脑常见问题";
$submenu="搜索帮助";
$templateMenu->assign('MENU',$menu);
$templateMenu->assign('SUBMENU',$submenu);
$templateMenu->output();
/*
获取URL后的变量
*/
if (empty($_SESSION['Qword'])){
	$Qword = $_GET["Qword"];
	$_SESSION['Qword'] = $Qword;
}else{
	$Qword = $_SESSION['Qword'];
}
/*
$tn 总记录数
*/
$sqltn="select count(*) from Article where Aclass = 2 and Atitle like '%{$Qword}%'";
$tn =$db->GetOne($sqltn);
/*
分页设置
计算页数
*/
$page_size = 15;
$tp = ceil($tn / $page_size);
$cp =(int)$_GET["p"];
empty($cp)==true ? $cp=1:$cp=(int)$_GET["p"];
if ($cp < 1) $cp   = 1 ;
if ($cp > $tp) $cp = $tp; 
/*
取记录
输出主体部分
*/
$sqlrs="select ID,Atitle,Aclass,Aeditor,Atime from Article where Aclass = 2 and Atitle like '%{$Qword}%'";
$rs = $db->SelectLimit($sqlrs,$page_size,($cp-1) * $page_size);
$rs = $rs->GetRows();
$templateMain->assign('class',$Qclass);
$templateMain->assign('article',$rs);
$templateMain->assign('CP',$cp);
$templateMain->assign('Pr',$cp-1);
$templateMain->assign('Ne',$cp+1);
$templateMain->assign('TP',$tp);
$templateMain->assign('TN',$tn);
$templateMain->output();
/*
输出页脚
*/
$templateBottom->output();
?>