#*********************************************************
#下面两个类可以保存为一个文件
#*********************************************************
class yl_class_sys
{
#*********************************************************
#数据列表类以对象方式
#*********************************************************
function list_info_main_obj($rs,$pagesize,$resultstr){
$leftline0='<div class=\'info_list info_line\'><ul>';
$list_info = $leftline0;
$i = 0;
while($rs = fetch_object($resultstr)){
$yl_id = $rs -> yl_id;
$yl_ttle = $rs->yl_title;
$yl_adddate = $rs->yl_adddate;
$list_info .= '<li>';
$list_info .= '<span class=dater time>[';
$list_info .= ''.$yl_adddate.'';
$list_info .= ']</span>';
$list_info .= ''.$yl_ttle.'';
$list_info .= '</li>';
if (($i % 5) == 0) {
$leftline1='</ul></div><div class=blank3></div>'.$leftline0.'';
$list_info .= $leftline1;
}
$i++;
if ($i > $pagesize)
break;
else
continue;
}
$list_info .= '</ul></div>';
return $this -> list_info_main_obj = $list_info;
}
#*********************************************************
#分页导航
#*********************************************************
function list_page($pageurl,$rsnum,$pages,$pagecount,$pagesize){
$pcount = $pages;
$page_info = '<div class=pagenum>';
$page_info .= '<div class=num>';
if (($pcount > 1) && ($pcount == $pagecount) ){
$page_info .= '<a href = '.$pageurl.'page='.intval($pagecount-1).'>上一页</a>';
}elseif (($pagecount != 1) && ($pcount != $pagecount)){
$page_info .= '<a href = '.$pageurl.'page='.intval($pagecount-1).'>上一页</a>';
}
$page_info .= '<a href = '.$pageurl.'page=1>页首</a>';
if ($pagecount > 4){
$page_info .= '<a href = '.$pageurl.'page=1>[1]</a><span class=dot>...</span>';
}
if ($pcount > $pagecount+2){
$endpage = $pagecount+2;
}else{
$endpage = $pcount;
}
for ($n = ($pagecount-2); $n <= $endpage; $n++){
if (!($n < 1)){
if ($n == intval($pagecount)){
$page_info .= '<span class=normal>'.$n.'</span>';
}else{
$page_info .= '<a href = '.$pageurl.'page='.$n.'>['.$n.']</a>';
}
}
}
if ($pagecount+2 < $pcount){
$page_info .= '<span class=dot>...</span><a href='.$pageurl.'page='.$pcount.'>['.$pcount.']</a>';
}
$page_info .= '<a href = '.$pageurl.'page='.$pcount.'>页尾</a>';
if (($pagecount == 1) && ($pcount != $pagecount) && ($pcount != 0)){
$page_info .= '<a href = '.$pageurl.'page='.intval($pagecount + 1).'>下一页</a>';
}else if (($pagecount != 1) && ($pcount != $pagecount)){
$page_info .= '<a href = '.$pageurl.'page='.intval($pagecount + 1).'>下一页</a>';
}
$page_info .= '</div></div>';
$page_info .= '<div class=pagenum>';
$page_info .= '<div class=num><span class=normal> 共:'.$rsnum .'条/'.$pcount.'页 每页/'.$pagesize.'条</span></div>';
$page_info .= ' <div class=num>';
//echo '<form name=page action='.$pageurl.'>';
$page_info .= ' 转到';
$page_info .= '<input type=text name=page value=\'1\' class=login_left style=\'width:28px;height:18px;\'>';
$page_info .= '页<input type=submit name=submit3 class=login_left style=\'width:28px;height:18px;padding-top:1px;\' onclick=document.myform.action.value=\'go\'> ';
//echo '</form>';
$page_info .= '</div>';
$page_info .= '</div>';
return $this -> list_page = $page_info;
}
}
class yl_class{
#*********************************************************
#数据查询类
#*********************************************************
function list_select($type_functionname,$pageurl,$getpage,$pageumn,$selecttable,$selectwhere,$selectstr,$orderbystr,$yl_dbname)
{
$yl_class_sys = new yl_class_sys();
if ($pageumn == ''){
$pageumn = 10;
}
if ($selecttable == ''){
$selecttable='yl_info';
}
if ($selectstr == ''){
$selectstr = '*';
}
if ($orderbystr == ''){
$selectstr = 'yl_adddate desc';
}
$sqlsrt = 'select '.$selectstr.' from '.$selecttable.' '.$selectwhere.' order by '.$orderbystr.'';
$resultstr = db_query($yl_dbname,$sqlsrt);
if (!$resultstr){
echo '很抱歉,查询失败.数据库可能在维护中,请稍后再试';
echo '<a href=admin_article_list.php><font color=red>返回</font></a>';
exit;
}
$rsnum = num_rows($resultstr);
if ($rsnum == 0){
echo '暂无数据';
exit;
}
if ($getpage == ''){
$pagecount = 1;
}else{
if (isset($getpage)){
$pagecount = intval($getpage);
}
}
$pagesize = $pageumn;
$pages = ceil($rsnum/$pagesize);
if($rsnum != 0){
data_seek($resultstr,(($pagecount-1)*$pagesize));//移动内部结果指针
}
$list_selectstr = $yl_class_sys -> $type_functionname($rs,$pagesize,$resultstr);//数据列表
$list_selectstr .= $yl_class_sys -> list_page($pageurl,$rsnum,$pages,$pagecount,$pagesize);//分页
return $this -> list_select = $list_selectstr;
}
}
?>
评论 {{userinfo.comments}}
{{child.content}}
{{question.question}}
提交