| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 566 人关注过本帖
标题:请帮忙加入分页代码
只看楼主 加入收藏
a190066
Rank: 4
等 级:业余侠客
威 望:2
帖 子:175
专家分:204
注 册:2010-6-24
结帖率:79.07%
收藏
已结贴  问题点数:20 回复次数:7 
请帮忙加入分页代码
<div align="center">
〈%
set rs=server.CreateObject("adodb.recordset")
sql="select id from scunews"
rs.open sql,cn,1,1
s=rs.recordcount
rs.close
set rs=nothing
set rs=server.CreateObject("adodb.recordset")
sql="select id from scunews where upup=1"
rs.open sql,cn,1,1
s1=rs.recordcount
rs.close
set rs=nothing
set rs=server.CreateObject("adodb.recordset")
sql="select id from scunews where downdown=1"
rs.open sql,cn,1,1
s2=rs.recordcount
rs.close
set rs=nothing
set rs=server.CreateObject("adodb.recordset")
sql="select id from scunews where jiajia=1"
rs.open sql,cn,1,1
s3=rs.recordcount
rs.close
set rs=nothing
%〉
<table width="61%" border="0" cellspacing="0" cellpadding="0">
  <tr align="center" valign="bottom">
    <td width="19%" height="20">总人数</td>
    <td width="23%">上班签到人数</td>
    <td width="29%">下班登记人数</td>
    <td width="29%">请假外出人数</td>
  </tr>
  <tr align="center">
    <td>〈%=s%〉</td>
    <td>〈%=s1%〉</td>
    <td>〈%=s2%〉</td>
    <td>〈%=s3%〉</td>
  </tr>
  <tr align="center" valign="bottom">
    <td height="188">百分比</td>
    <td height="188"><div style="background-color:#98C9D6; width: 20px; height: 〈%=(s1/s)*30%〉px;"></div></td>
    <td height="188"><div style="background-color:#98C9D6; width: 20px; height: 〈%=(s2/s)*30%〉px;"></div></td>
    <td height="188"><div style="background-color:#98C9D6; width: 20px; height: 〈%=(s3/s)*30%〉px;"></div></td>
  </tr>
</table>
<hr size="2px" color="#218FF3">

<table width="61%" border="0" cellspacing="0" cellpadding="0">
  <tr align="center">
    <td width="19%">账户</td>
    <td width="23%">上班签到</td>
    <td width="29%">下班登记</td>
    <td width="29%">请假外出</td>
  </tr>
<!需要在此开始分页->
  〈%
  set rs=cn.execute("select * from scunews")
  do while not rs.eof
  %〉
  <tr align="center">
    <td align="left">&nbsp;&nbsp;&nbsp;&nbsp;〈%=rs("username")%〉</td>
    <td><div id="div1">
      〈%if rs("upup")=0 then%〉
      <a href="?act=upup&id=〈%=rs("id")%〉"><font color="#FF0000">未签到</font></a>
      〈%else%〉
      <a href="?key=upup&id=〈%=rs("id")%〉">已签到</a>
      〈%end if%〉
    </div></td>
    <td>〈%if rs("downdown")=0 then%〉
      <a href="?act=downdown&id=〈%=rs("id")%〉">未登记</a>
        〈%else%〉
        <a href="?key=downdown&id=〈%=rs("id")%〉"><font color="#FF0000">已登记</font></a>
      〈%end if%〉</td>
    <td><div id="div">
      〈%if rs("jiajia")=0 then%〉
      <a href="?act=jiajia&id=〈%=rs("id")%〉">未请假</a>
      〈%else%〉
      <a href="?key=jiajia&id=〈%=rs("id")%〉"><font color="#FF0000">已请假</font></a>
      〈%end if%〉
    </div></td>
  </tr>
  〈%
  rs.movenext
  loop
  conn.close
  %〉
</table>
〈%
id=request("id")
if request("act")<>"" then
set rs=cn.execute("update scunews set "&request("act")&"=1 where id="&id&"")
conn.close
response.Redirect("qiandao_look.asp")
end if
if request("key")<>"" then
set rs=cn.execute("update scunews set "&request("key")&"=0 where id="&id&"")
conn.close
response.Redirect("qiandao_look.asp")
end if
%〉
</div>
搜索更多相关主题的帖子: 代码 
2010-07-11 17:20
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:7 
程序代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--#include file="CONDB.inc"-->
<!--引用数据库连接文件-->
<!--#include file="Cls\WebSiteSetInf.asp"-->
<%
   '声明数据库记录集对象
   Dim rsano
   Dim oWebI
   '创建数据库记录集对象
   Set rsano=Server.CreateObject("ADODB.Recordset")
   '设定数据库记录集游标类型
   rsano.cursortype=3
   '打开记录集对象
   rsano.Open "select * From ANOUCE ORDER BY AnnounceTheDate DESC",con
   '设定每页显示记录数
   rsano.pagesize=25
   '得到请求的页号
   page=clng(request("page"))
   IF request("page")<>"" then
     page=clng(request("page"))
   Else
     page=1
   End IF
   IF page<1 Then page=1
   If page>rsano.pagecount Then page=rsano.pagecount
   rsano.absolutepage=page
   '网页样式初始化代码
%>
<title><%=oWebI.WebName%>-网站公告页面</title>
<!--去除超连接下划线样式表和字体大小设定代码-->
<style type="text/css">
<!--
  <%=PageStyleT.StyleString%>
-->
</style>
<STYLE type=text/css>
A {
    TEXT-TRANSFORM: none; TEXT-DECORATION: none
}
UNKNOWN {
    TEXT-DECORATION: underline
}
.style22 {font-size: 12px}
.style16 {font-size: 14px}
BODY {
    background-color: <%=PageStyleT.BackGround%>;
}
</STYLE>
</head>

<BODY>

<table width="294" height="46" border="0" cellspacing="0">
  <tr>
    <td width="338"><div align="center" class="style22">公告标题</div></td>
    <td width="95"><div align="center" class="style22">发布日期</div></td>
  </tr>
  <%
  '定义循环变量
  dim iPage
  For iPage=1 to rsano.Pagesize
   'recno=(page-1)*rsano.pagesize+ipage记录编号计算公式
   Response.Write("<tr>")
     Response.write("<td><span class=style16><a href=announceview.asp?anbh="&rsano.Fields(0).Value&" target=_self>"&rsano.Fields(1).Value&"</a></span></td>")
     Response.Write("<td><span class=style22>"&FormatDateTime(rsano.Fields(4).Value,2)&"</span></td>")
   Response.Write("</tr>")
   rsano.MoveNext
   IF rsano.EOF Then
      Exit For
   End If
  Next
  %>
</table>
<table width="293" border="0">
  <tr>
  <%
  '翻页控制代码
  IF page<>1 Then
    Response.Write("<td><span class=style22><a href=announce.asp?page=1>第一页</a></span></td>")
    Response.Write("<td><span class=style22><a href=announce.asp?page="&(page-1)&">上一页</a></span></td>")
  Else
    Response.Write("<td><span class=style22>第一页</span></td>")
    Response.Write("<td><span class=style22>上一页</span></td>")
  End IF   
  IF page<>rsano.pagecount then
    Response.Write("<td><span class=style22><a href=announce.asp?page=" & (page+1) & ">下一页</a></span></td>")
    Response.Write("<td><span class=style22><a href=announce.asp?page=" & rsano.pagecount & ">最后一页</a></span></td>")
  Else
    Response.Write("<td><span class=style22>下一页</span></td>")
    Response.Write("<td><span class=style22>最后一页</span></td>") 
  End IF
  %>
    <td><span class=style22><%=rsano.pagecount%></span></td>
    <td><span class=style22>当前第<%=page%></span></td>
  </tr>
</table>
<%
'网页对象析构代码
rsano.Close
con.Close
Set rsano=Nothing
Set con=Nothing
%>
</body>
</html>
最简单的分页代码
2010-07-12 11:21
a190066
Rank: 4
等 级:业余侠客
威 望:2
帖 子:175
专家分:204
注 册:2010-6-24
收藏
得分:0 
回复 楼主 a190066
在原代码上加入分页代码出现错误,请高手指教。
<!--#include file="conn.asp"-->
<div align="center">
<%
set rs=server.CreateObject("adodb.recordset")
sql="select id from scunews"
rs.open sql,cn,1,1
s=rs.recordcount
rs.close
set rs=nothing
set rs=server.CreateObject("adodb.recordset")
sql="select id from scunews where upup=1"
rs.open sql,cn,1,1
s1=rs.recordcount
rs.close
set rs=nothing
set rs=server.CreateObject("adodb.recordset")
sql="select id from scunews where downdown=1"
rs.open sql,cn,1,1
s2=rs.recordcount
rs.close
set rs=nothing
set rs=server.CreateObject("adodb.recordset")
sql="select id from scunews where jiajia=1"
rs.open sql,cn,1,1
s3=rs.recordcount
rs.close
set rs=nothing
%>

<%
dim i,intPage,page,pre,last,filepath
set rs = server.CreateObject("adodb.recordset")
sql="select * from scunews order by username_ID desc"
rs.PageSize = 20 '这里设定每页显示的记录数
rs.CursorLocation = 3
rs.Open sql,conn,0,2,1 '这里执行你查询SQL并获得结果记录集
pre = true
last = true
page = trim(Request.QueryString("page"))

if len(page) = 0 then
intpage = 1
pre = false
else
if cint(page) =< 1 then
intpage = 1
pre = false
else
if cint(page) >= rs.PageCount then
intpage = rs.PageCount
last = false
else
intpage = cint(page)
end if
end if
end if
if not rs.eof then
rs.AbsolutePage = intpage
end if
%>
<table width="61%" border="0" cellspacing="0" cellpadding="0">
  <tr align="center" valign="bottom">
    <td width="19%" height="20">总人数</td>
    <td width="23%">上班签到人数</td>
    <td width="29%">下班登记人数</td>
    <td width="29%">请假外出人数</td>
  </tr>
  <tr align="center">
    <td><%=s%></td>
    <td><%=s1%></td>
    <td><%=s2%></td>
    <td><%=s3%></td>
  </tr>
  <tr align="center" valign="bottom">
    <td height="310">百分比</td>
    <td height="310"><div style="background-color:#98C9D6; width: 20px; height: <%=(s1/s)*30%>px;"></div></td>
    <td height="310"><div style="background-color:#98C9D6; width: 20px; height: <%=(s2/s)*30%>px;"></div></td>
    <td height="310"><div style="background-color:#98C9D6; width: 20px; height: <%=(s3/s)*30%>px;"></div></td>
  </tr>
</table>
<hr size="2px" color="#218FF3">

<table width="61%" border="0" cellspacing="0" cellpadding="0">
  <tr align="center">
    <td width="19%">账户</td>
    <td width="23%">上班签到</td>
    <td width="29%">下班登记</td>
    <td width="29%">请假外出</td>
  </tr>

 <%
  set rs=cn.execute("select * from scunews")
  do while not rs.eof
  %>

  <%
  set rs=cn.execute("select * from scunews")
  do while not rs.eof
  %>
 
  <tr align="center">
    <td align="left">&nbsp;&nbsp;&nbsp;&nbsp;<%=rs("username")%></td>
    <td><div id="div1">
      <%if rs("upup")=0 then%>
      <a href="?act=upup&id=<%=rs("id")%>"><font color="#FF0000">未签到</font></a>
      <%else%>
      <a href="?key=upup&id=<%=rs("id")%>">已签到</a>
      <%end if%>
    </div></td>
    <td><%if rs("downdown")=0 then%>
      <a href="?act=downdown&id=<%=rs("id")%>">未登记</a>
        <%else%>
        <a href="?key=downdown&id=<%=rs("id")%>"><font color="#FF0000">已登记</font></a>
      <%end if%></td>
    <td><div id="div">
      <%if rs("jiajia")=0 then%>
      <a href="?act=jiajia&id=<%=rs("id")%>">未请假</a>
      <%else%>
      <a href="?key=jiajia&id=<%=rs("id")%>"><font color="#FF0000">已请假</font></a>
      <%end if%>
    </div></td>
  </tr>

 <%
  rs.movenext
  loop
  conn.close
  %>
</table>

<%
id=request("id")
if request("act")<>"" then
set rs=cn.execute("update scunews set "&request("act")&"=1 where id="&id&"")
conn.close
response.Redirect("qiandao_look.asp")
end if
if request("key")<>"" then
set rs=cn.execute("update scunews set "&request("key")&"=0 where id="&id&"")
conn.close
response.Redirect("qiandao_look.asp")
end if
%>

<table width="99%" border="1" cellpadding="2" cellspacing="2" borderColorLight=#808080 borderColorDark=#ffffff>
<tr>
<%if rs.pagecount > 0 then%>
<td width="13%" align="left">当前页<%=intpage%>/<%=rs.PageCount%></td>
<%else%>
<td width="41%" align="left">当前页0/0</td><%end if%>
<td width="46%" align="right"> <a href="document_manage.asp?page=1">首页</a>|
<%if pre then%>
<a href="document_manage.asp?page=<%=intpage -1%>">上页</a>| <%end if%>
<%if last then%>
<a href="document_manage.asp?page=<%=intpage +1%>">下页</a> |<%end if%>
<a href="document_manage.asp?page=<%=rs.PageCount%>">尾页</a>|转到第
<select name="sel_page" onchange="javascript:location=this.options[this.selectedIndex].value;">
<%
for i = 1 to rs.PageCount
if i = intpage then%>
<option value="document_manage.asp?page=<%=i%>" selected><%=i%></option>
<%else%>
<option value="document_manage.asp?page=<%=i%>"><%=i%></option>
<%
end if
next
%>
</select>页</font></td></tr></table></div>

2010-07-12 12:05
a190066
Rank: 4
等 级:业余侠客
威 望:2
帖 子:175
专家分:204
注 册:2010-6-24
收藏
得分:0 
以下代码可显示分页码,有上一页、下一页提示。但修改“rs.pagesize=10”此数实际上不能改页码数,还是显示超过10行以上的内容。实际上没有分页。请高手指教!谢谢

<!--#include file="conn2.asp"-->
<link href=font.css rel=stylesheet>
<div align="center">

<%
set rs=server.CreateObject("adodb.recordset")
sql="select id from scunews"
rs.open sql,cn,1,1
s=rs.recordcount
rs.close
set rs=nothing

set rs=server.CreateObject("adodb.recordset")
sql="select id from scunews where up1=1"
rs.open sql,cn,1,1
s=rs.recordcount
rs.close
set rs=nothing

set rs=server.CreateObject("adodb.recordset")
sql="select id from scunews where up2=1"
rs.open sql,cn,1,1
s1=rs.recordcount
rs.close
set rs=nothing

set rs=server.CreateObject("adodb.recordset")
sql="select id from scunews where up3=1"
rs.open sql,cn,1,1
s2=rs.recordcount
rs.close
set rs=nothing
%>

<div align="center"><center>
<table border="1" borderColor="#000000" cellPadding="0"
style="border-collapse: collapse; border-bottom: medium none" width="100%" cellspacing="1">

 

  <tr>
    <td width="6%" align="center"><b><font color="#FF0000"><%=s%></font></b><font color="#800000">次</font></td>
    <td width="6%" align="center"><font color="#FF0000"><b><%=s1%></font></b><font color="#800000">次</font></td>
    <td width="6%" align="center"><font color="#FF0000"><b><%=s2%></font></b><font color="#800000">次</font></td>
  </tr>
 
</table>
<hr size="1px" color="#218FF3">

<%
dim page
page=Clng(request("page"))
rs.pagesize=10'此值设置十行一页但修改此数实际上不能改页码数,请高手指教!谢谢
if page<1 then page=1
if page>rs.pagecount then page=rs.pagecount
rs.Absolutepage=page
%>

<div align="center"><center>
<table border="1" borderColor="#000000" cellPadding="0"
style="border-collapse: collapse; border-bottom: medium none" width="100%" cellspacing="1">

 
<%
for i=1 to rs.pagesize
%>

  <%
  set rs=cn.execute("select * from scunews")
  do while not rs.eof
  %>

  <tr align="center">

    <td width="6%" align="center"><div id="div1">
      <%if rs("up1")=0 then%>
      <a href="?act=up1&id=<%=rs("id")%>">已签到</a>
      <%else%>
      <a href="?key=up1&id=<%=rs("id")%>"><font color="#FF0000">未签到</font></a>
      <%end if%>
    </div></td>

    <td width="6%" align="center"><%if rs("up2")=0 then%>
      <a href="?act=up2&id=<%=rs("id")%>">已签到</a>
        <%else%>
        <a href="?key=up2&id=<%=rs("id")%>"><font color="#FF0000">未签到</font></a>
      <%end if%></td>

    <td width="6%" align="center"><div id="div">
      <%if rs("up3")=0 then%>
      <a href="?act=up3&id=<%=rs("id")%>">已签到</a>
      <%else%>
      <a href="?key=up3&id=<%=rs("id")%>"><font color="#FF0000">未签到</font></a>
      <%end if%>
    </div></td>
  </tr>

  <%
  rs.movenext
  loop
  conn.close
  %>

</table>
</div>

<%
id=request("id")
if request("act")<>"" then
set rs=cn.execute("update scunews set "&request("act")&"=1 where id="&id&"")
conn.close
response.Redirect("2index.asp")
end if
if request("key")<>"" then
set rs=cn.execute("update scunews set "&request("key")&"=0 where id="&id&"")
conn.close
response.Redirect("2index.asp")
end if
%>
<%
rs.movenext
if rs.eof then exit for
next
%>
<%
if page<>1 then
response.write "<a href=2index.asp?page=1>首页</a> "
response.write "<a href=2index.asp?page="&(page-1)&">上一页</a> "
end if
if page<>rs.pagecount then
response.write "<a href=2index.asp?page="&(page+1)&">下一页</a> "
response.write "<a href=2index.asp?page="&rs.pagecount&">尾页</a> "
end if
%>

</div>


[ 本帖最后由 a190066 于 2010-7-12 14:06 编辑 ]
2010-07-12 14:05
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
你数据库里的数据超过了10行了?
2010-07-12 21:58
a190066
Rank: 4
等 级:业余侠客
威 望:2
帖 子:175
专家分:204
注 册:2010-6-24
收藏
得分:0 
回复 4楼 a190066
不行哟。设定十行的。但超过13行还是显示13行。我就是想不通。再帮我查查。谢谢。

我再把数据库的相关二个文件传上来,请高手查对一下。
Question.rar包含如下文件:
Question.rar (9.73 KB)

2index.asp
conn.asp
font.css
pingfen.mdb (188KB)


[ 本帖最后由 a190066 于 2010-7-13 02:29 编辑 ]
2010-07-13 01:54
yanhaolang
Rank: 1
等 级:新手上路
帖 子:60
专家分:7
注 册:2007-3-12
收藏
得分:7 
这年头不要搞asp啊。。看着晕
2010-07-14 16:13
快速回复:请帮忙加入分页代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.052129 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved