| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 412 人关注过本帖
标题:这是一个分页程序,请大家帮我解决个问题
只看楼主 加入收藏
oooaaa_m
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2007-3-15
收藏
 问题点数:0 回复次数:2 
这是一个分页程序,请大家帮我解决个问题
<% dim action action=request.QueryString("action") Const MaxPerPage=10 '定义每页显示记录数 dim totalPut dim CurrentPage dim TotalPages dim j dim sql if Not isempty(request("page")) then currentPage=Cint(request("page")) else currentPage=1 end if %> <% set rs=server.CreateObject("adodb.recordset") rs.open "select * from test",conn,1,1 %> <% a="news" '这个是定义不同条件下打开数据表,以定义调用分页程序文件的参数。可多加参数,但要相应修改后面的参数。 if err.number<>0 then response.write "

数据库中暂时无数据

" end if if rs.eof And rs.bof then Response.Write "

对不起,没有符合条件记录!

" else totalPut=rs.recordcount if currentpage<1 then currentpage=1 end if if (currentpage-1)*MaxPerPage>totalput then if (totalPut mod MaxPerPage)=0 then currentpage= totalPut\MaxPerPage else currentpage= totalPut\MaxPerPage + 1 end if end if if currentPage=1 then showContent showpage totalput,MaxPerPage,"fylogo.asp?lx="&a&"" else if (currentPage-1)*MaxPerPage <% sub showContent dim i i=0 do while not rs.eof%> <%i=i+1 if i>=MaxPerPage then Exit Do rs.movenext loop rs.close set rs=nothing End Sub %> <% Function showpage(totalnumber,maxperpage,filename) Dim n If totalnumber Mod maxperpage=0 Then n= totalnumber\maxperpage Else n= totalnumber\maxperpage+1 End If %>
>

<% if CurrentPage<2 Then %> 首 页 上一页 <% Else %> &page=1>首 页 &page=<% = CurrentPage-1 %>>上一页 <% End If If n-currentpage<1 Then %> 下一页 尾 页 <% Else %> &page=<% = (CurrentPage+1) %>>下一页 &page=<% = n %>>尾 页 <% End If %> 页次:<% = CurrentPage %>/<% = n %><%=maxperpage%>个记录/页 共<%=totalnumber %>

<%End Function%> 为什么我显示的内容不是当天发表的内容.而是以前显示的内容为第一条记录输出
2007-03-17 08:19
做人很低调
Rank: 5Rank: 5
等 级:贵宾
威 望:18
帖 子:1268
专家分:0
注 册:2006-8-2
收藏
得分:0 
整理一下在发帖啊
这样看的眼睛好累

其实我很低调,只是你不知道...
2007-03-17 08:48
yyjjto2002
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2007-3-21
收藏
得分:0 
想要当天发表的文章显示在列表的最前端,只需对数据进行排序即可.
按ID以倒序排序即从大到小(如从小到大,则把desc改成asc)
<% set rs=server.CreateObject("adodb.recordset") rs.open "select * from test order by id desc",conn,1,1%>
按时间,同上
<% set rs=server.CreateObject("adodb.recordset") rs.open "select * from test order by uptime desc",conn,1,1%>

两只刺猬的距离!
2007-03-21 17:59
快速回复:这是一个分页程序,请大家帮我解决个问题
数据加载中...
 
   



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

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