济宁京杭假日酒店:做留言板怎么做分页显示

来源:百度文库 编辑:高校问答 时间:2024/05/04 21:50:32
就是做成可以显示1、2、3...页的那种。留的言多了,一页中装不完了,怎么让它上下一页里面里,用ASP代码怎么编啊
做这个分页显示还用不用数据库啦?

<?php
require_once("../inc/inc.php");

if ($_GET["category_id"] == "") {
$category_id = -1;
} else {
$category_id = (integer)$_GET["category_id"];
}
if(!$_GET["pageno"]) {
$pageno = 1;
} else {
$pageno = (integer)$_GET["pageno"];
}

$pagesize = $pagesize_config;if(!$pagesize){$pagesize = 30;}
if ($_GET["submit"] != "搜索"){
$groups = $attribute_groupsql->select_group_by_category_id($category_id);
}
else{
$groups = $attribute_groupsql->select_group_by_category_id_and_word($category_id,trim($_GET["wd"]));
}
$rscount = $groups->recordcount();
$pagestart = $pagesize * ($pageno - 1);
$pageend = $pagestart + $pagesize;

if (!$rscount%$pagesize) {
$totalpage = $rscount / $pagesize;
} else {
$totalpage = ($rscount - $rscount%$pagesize) / $pagesize + 1;
}
?>
<html lang="zh">
<meta http-equiv="Content-Type" content="text/html;charset=GB2312">
<head>
<title>属性组列表</title>
<link rel=stylesheet type="text/css" href="../css.css">
<script language="javascript" src="../js/window.js"></script>
</head>

<body style="margin:10 10 10 10" onload=document.search.wd.focus()>

<table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%" align="center">
<tr><td class="alt1" width="100%">
<a title="无框架模式" href="../main.php?cols=0&file=<?php echo $PHP_SELF;?>" target="_top"><img src="../images/navbits_start.gif" border="0"></a><a title="框架模式" href="../main.php?cols=15&file=<?php echo $PHP_SELF;?>" target="_top"><img src="../images/xlink.gif" border="0"></a>
<span class="navbar">属性组管理</span>
</td></tr>
</table>

<form name="search" action=<?php echo $PHP_SELF;?> method="GET">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr valign="middle" height="40">
<td width="190" nowrap>
<a href="addgroup.php?category_id=<?php echo $category_id;?>" target="_blank"><font color="#CC0000">添加属性组</font></a>
</td>
<td nowrap>
搜索关键字: <input type="text" name="wd" value="<?php echo trim($_GET["wd"]);?>">
<input type="hidden" name="category_id" value="<?php echo $category_id;?>">
<input type="hidden" name="group_id" value="<?php echo $group_id;?>">
<input type="hidden" name="rscount" value="<?php echo $rscount;?>">
<input type="submit" name="submit" value="搜索">
</td>
<td align="right" nowrap>
共有<font color=#CC0000><?php echo $rscount;?></font>个属性组
每页<font color=#CC0000><?php echo $pagesize;?></font>个
本页<font color=#CC0000><?php if($totalpage>$pageno){echo $pagesize;}else{echo ($rscount-($pageno-1)*$pagesize);}?></font>个
</td>
</tr>
</table>
</form>

<form name="frm" action="mdo.php" method="POST">
<table width="80%" align=center cellSpacing=1 cellPadding=3 class="tborder">
<tr valign="middle" class="T1" style="color:#FFFFFF; font-weight: bold">
<td align="center"><div align="center">属性组编号</div></td>
<td align="center"><div align="center">属性组名称</div></td>
<td align="center"><div align="center">次序</div></td>
<td align="center"><div align="center">编辑选项</div></td>
</tr>
<?php
while(!$groups->EOF){
if($i>=$pagestart && $i<$pageend){
if(!$j){
$j=$pagestart;
}
?>
<tr valign="middle" class="T<?php echo $i%2+2;?>">
<td align="center"><div align="center">
<?php echo $groups->Fields("GROUP_ID");?>
</div></td>
<td align="center"><div align="center">
<a href="../attribute/index.php?category_id=<?php echo $category_id;?>&group_id=<?php echo $groups->Fields("GROUP_ID");?>"><font color="#"><b><?php echo $groups->Fields("NAME");?></b></font></a>
</div></td>
<td align="center"><div align="center">
<font color="#999999"><?php echo $groups->Fields("SORT_ORDER");?></font>
</div></td>
<td align="center"><div align="center">
<a href="#" onclick="new_window('editgroup.php?category_id=<?php echo $category_id;?>&group_id=<?php echo $groups->Fields("GROUP_ID");?>')"><font color=green>编辑</font></a>
<input name="checkbox<?php echo (integer)$i?>" type="checkbox" value="<?php echo $groups->Fields("GROUP_ID");?>">
</div></td>
</tr>
<?php
$j++;
}
$i++;
$groups->movenext();
}
?>
<tr><td align="right" colspan="3">
<input type="hidden" name="pageno" value="<?php echo $pageno;?>">
<input type="hidden" name="rscount" value="<?php echo $rscount;?>">
<input type="hidden" name="category_id" value="<?php echo $category_id;?>">
<input type="button" name ="true" value="全选" onclick="javascript:
<?php for($i=$pagestart;$i<$j;$i++){echo "document.frm.checkbox".$i.".checked=true;";}?>">
<input type="button" name ="false" value="全否" onclick="javascript:
<?php for($i=$pagestart;$i<$j;$i++){echo "document.frm.checkbox".$i.".checked=false;";}?>">
<input type="button" name ="false" value="反选" onclick="javascript:
<?php for($i=$pagestart;$i<$j;$i++){echo "if(document.frm.checkbox".$i.".checked==false){document.frm.checkbox".$i.".checked=true;}else{document.frm.checkbox".$i.".checked=false;}";}?>">
<input type="submit" name ="submit" value="删除所选" onclick="javascript:return tishi();">
<?php if($category_level!=0){?>
<input type="submit" name ="submit" value="更改父属性组">
<?php }?>
</form>
</td><td align="right" colspan="1">
<form name="page" method="GET" action="<?php echo $PHP_SELF;?>">
<select name="pageno" onchange="javascript:window.location=('<?php echo $PHP_SELF;?>?submit=<?php echo $_GET["submit"];?>&wd=<?php echo trim($_GET["wd"]);?>&category_id=<?php echo $category_id;?>&pageno='+this.options[this.selectedIndex].value)">
<?php
for($i=1;$i<=$totalpage;$i++){
echo "\t\t\t<option value=".$i;
if($pageno==$i){echo " selected";}
echo ">第".$i."页</option>\n";
}
?>
</select>
<input type="hidden" name="category_id" value="<?php echo $category_id;?>">
</form>
</td></tr>
</table>
</body>
</html>

<%
'**************************************************
'过程名:ShowPage
'作 用:显示“上一页 下一页”等信息
'参 数:sDescURL ——链接地址,可以是一个文件名,也可以是一个有一些参数的URL
' nTotalNumber ——总数量
' nMaxPerPage ——每页数量
' nCurrentPage ——当前页
' bShowTotal ——是否显示总数量
' bShowCombo ——是否用下拉列表显示所有页面以供跳转
' sUnit ——计数单位
'**************************************************
Sub ShowPage(sDescURL, nTotalNumber, nMaxPerPage, nCurrentpage, bShowTotal, bShowCombo, sUnit)
Dim n, i, strTemp, strUrl
'计算页数
If nTotalNumber mod nMaxPerPage = 0 Then
n = ntotalNumber \ nMaxPerPage
Else
n = nTotalNumber \ nMaxPerPage +1
End If
'判断nCurrentPage
If nCurrentPage < 1 Then
nCurrentPage = 1
ElseIf nCurrentPage > n Then
nCurrentPage = n
End If

strTemp = "<table align='center' ID='Table1'><form name='ShowPages' method='post' action='" & sDescURL & "' ID='Form1'><tr><td>"
If bShowTotal = True Then
strTemp = strTemp & "共<b>" & nTotalNumber & "</b>" & sUnit & "  "
End If
'根据输入的sDescURL向它加入“?”或“&”
strUrl = PasteURL(sDescURL)
If nCurrentPage < 2 Then
strTemp = strTemp & "首页 上一页 "
Else
strTemp = strTemp & "<a href='" & strUrl & "page=1'>首页</a> "
strTemp = strTemp & "<a href='" & strUrl & "page=" & (nCurrentPage - 1) & "'>上一页</a> "
End If

If n - nCurrentPage < 1 Then
strTemp = strTemp & "下一页 尾页"
Else
strTemp = strTemp & "<a href='" & strUrl & "page=" & (nCurrentPage + 1) & "'>下一页</a> "
strTemp = strTemp & "<a href='" & strUrl & "page=" & n & "'>尾页</a>"
End If
strTemp = strTemp & " 页次:<strong><font color=red>" & nCurrentPage & "</font>/" & n & "</strong>页"
strTemp = strTemp & " <b>" & nMaxPerPage & "</b>" & sUnit & "/页"
If bShowCombo = True Then
strTemp = strTemp & " 转到:<select name='page' size='1' onchange='javascript:submit()' ID='Select1'>"
For i = 1 To n
strTemp = strTemp & "<option value='" & i & "'"
If cint(nCurrentPage) = cint(i) Then strTemp = strTemp & " selected "
strTemp = strTemp & ">第" & i & "页</option>"
Next
strTemp = strTemp & "</select>"
End If
strTemp = strTemp & "</td></tr></form></table>"
Response.Write(strTemp)
End Sub

'**************************************************
'函数名:PasteURL
'作 用:向地址中加入“?”或“&”
'参 数:strUrl——网址
'返回值:加了“?”或“&”的网址
'**************************************************
Function PasteURL(strUrl)
If strUrl = "" Then
PasteURL = ""
Exit Function
End If
'如果传入的URL末尾不是“?”,有两种情况:
'1.无“?”,此时需加入一个“?”
'2.有“?”,再判断有无“&”
If InStr(strUrl,"?") < len(strUrl) Then
If InStr(strUrl,"?") > 1 Then
If InStr(strUrl,"&") < len(strUrl) Then
PasteURL = strUrl & "&"
Else
PasteURL = strUrl
End If
Else
PasteURL = strUrl & "&"'yuanlai shi ?
End If
Else
PasteURL = strUrl
End If
End Function
%>

给的分好少哦~~~~,不会调用这个函数再问我吧,我再回答~~~

ASP的?