100分,急救,好怪的分页程序

computer110 2004-05-07 04:31:16
点‘下一页’http://localhost/hongli/Class.asp?PageNo=2
老是显示:
"无相关文章分类!"
"请按这儿返回"
这是什么原因呀,好怪! 老是不能显示下一页的内容,但地址栏那显示的的路径确是对的

<!--#include file="../hongli/inc/conn.asp"-->
<%
class_id=request("class_id")
if class_id="" then
response.write("<br>"&"<p>")
Response.Write "<center>无相关文章分类!</center>"
response.write "<br>"
response.write "<center><a href=./index.asp>请按这儿返回</a></center>"
Response.End
else%>
<!--#include file="./public/class.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>魔法小丫头</title>

<link href="index.css" rel="stylesheet" type="text/css">
</head>

<body background="image/background.gif" topmargin="0" marginheight="0">
<table width="600" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#999999">
<tr>
<td><table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><img src="image/logo.jpg" width="600" height="80"></td>
</tr>
</table>
<table width="600" height="19" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="19" background="image/a1.jpg">
<a href="index.asp" > 首页</a>

<%
dim rs
set rs=server.createobject("adodb.recordset")
rs.open "select * from class ",conn,1,1
do while not rs.eof
%>
   <a href="./class.asp?class_id=<%=rs("class_id")%>"><%=rs("class_name")%></a>
<%rs.movenext
loop
rs.close
%></td>
</tr>
</table></td>
</tr>
</table>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#666666">
<tr>
<td>
<table width="100%" height="35" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td background="./image/txt_css.gif" class="main"> 当前位置->><a href="index.asp">首页</a>->> <a href="./class.asp?class_id=<%=tclass(0)%>"><%=tclass(1)%></a>


</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="89%"><div align="center"></div></td>
<td width="11%"> </td>
</tr>
</table>
<table width="600" height="284" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="181" valign="top"> <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#f0f0f0">
<tr>
<td height="27" background="image/title_blue.gif" class="main">     本站分栏</td>
</tr>
<tr>
<td> <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td> <%set rs=conn.execute("SELECT * FROM nclass where class_id="&tclass(0))
if rs.bof and rs.eof then
response.write "近期无更新分类"
else
do while not rs.eof
%><a href="./nclass.asp?nclass_id=<%=rs("nclass_id")%>"><%=rs("nclass_name")%></a><br>
<%
rs.movenext
loop
end if
rs.close
%></td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#f0f0f0">
<tr>
<td height="27" background="image/title_11212.gif" class="main">     友情链接</td>
</tr>
<tr>
<td> <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td> </td>
</tr>
</table></td>
</tr>
</table></td>
<td width="12"> </td>
<td width="407" valign="top"> <table width="100%" height="24" border="0" cellpadding="0" cellspacing="0">

<tr>
<td width="2%" background="image/title2.gif"> </td>
<td width="95%" background="image/title2_11212.gif">[<%=tclass(1)%>]</td>
<td width="3%" background="image/title2_2.gif"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
</table>
<table width="100%" height="24" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="2%" background="image/title2.gif"> </td>
<td width="95%" background="image/title2_11212.gif"> </td>
<td width="3%" background="image/title2_2.gif"> </td>
</tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> <%
set rs1=Server.CreateObject("Adodb.Recordset")
sql= "SELECT * From nclass where class_id="&class_id
rs1.open sql,conn,1,1

set rs=Server.CreateObject("Adodb.Recordset")
sql= "SELECT * From news where nclass_id in ("&rs1("nclass_id")&") ORDER BY news_id DESC"
rs.open sql,conn,1,1
Dim TotalPage '总页数
Dim PageNo '当前显示的是第几页
Dim RecordCount '总记录条数
If RS.RecordCount=0 then
response.write "<P><center><font color=red>对不起,没有下级目录</font></center></P>"
response.end
else
RS.PageSize = 5
Totalpage=INT(RS.recordcount / rs.pagesize * -1)*-1 '计算可显示页面的总数
PageNo = Request.QueryString ("PageNo")
'直接输入页数跳转;
If Request.Form("PageNo")<>"" Then PageNo = Request.Form("PageNo")
'如果没有选择第几页,则默认显示第一页;
If PageNo = "" then PageNo = 1
Rs.AbsolutePage = PageNo
End If
'获取当前文件名,使得每次翻页都在当前页面进行;
Dim fileName,postion
fileName = Request.ServerVariables("script_name")
postion = InstrRev(fileName,"/")+1
'取得当前的文件名称,使翻页的链接指向当前文件;
fileName = Mid(fileName,postion)
Dim RowCount
RowCount = 5 '每页显示的记录条数
%>
<%
if rs.bof and rs.eof then
response.write "近期无更新文章"
else
Do while Not Rs.eof and RowCount>0


response.write "<a href='./type.asp?news_id="&rs("news_id")
response.write "' target='_blank'>"&rs("news_title")
response.write "</a><br>"


RowCount = RowCount - 1
Rs.MoveNext
Loop
end if
%></td>
</tr>
<tr>
<td><!--#include file="./public/search_page.asp"--></td>
</tr>
</table></td>
</tr>
</table> </td>
</tr>
</table>
<p class="main"> </p>
</body>
</html>
<%end if%>
...全文
78 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaozhi530 2004-05-09
  • 打赏
  • 举报
回复
同意 龙辉
chang1216 2004-05-09
  • 打赏
  • 举报
回复
你没有理解 翻页的内涵!!传到下一页时 不是也要request一个class_id吗 所以在下一页和上一页的链接上&class_id=<%=class_id%>就可以了!!!!
computer110 2004-05-09
  • 打赏
  • 举报
回复
class_id=request("class_id")
if class_id="" then
response.write("<br>"&"<p>")
Response.Write "<center>无相关文章分类!</center>"
response.write "<br>"
response.write "<center><a href=./index.asp>请按这儿返回</a></center>"
Response.End

开头这里不是接受class_id值 吗
Newrocky 2004-05-09
  • 打赏
  • 举报
回复
你的CLASS_ID的值从哪里来啊???
computer110 2004-05-09
  • 打赏
  • 举报
回复
现在我是要解决nclass页进行翻页,
class页可以翻页
liuyangxuan 2004-05-09
  • 打赏
  • 举报
回复
&
xuanhu 2004-05-09
  • 打赏
  • 举报
回复
将值进行传递啊,晕倒,这是遇到的第几个相同问题了啊,CSDN里面有很多相同的例子的。
computer110 2004-05-09
  • 打赏
  • 举报
回复
这是我后面改的,开始我的<a href="<%=fileName%>?PageNo=1&class_id=<%=class_id%>">首页,和你一样,那是在class页,但换到nclass页,进行翻页的时候,我就改成了<a href="<%=fileName%>?PageNo=1&class_id=<%=nclass_id%>">
请问我要怎样做,在class和nclass都可以调用同一个翻页函数
yougold 2004-05-09
  • 打赏
  • 举报
回复
同意 龙辉
angelheavens 2004-05-09
  • 打赏
  • 举报
回复
没有传递class_id过去,修改:
<a href="<%=fileName%>?PageNo=1&class_id=<%=class_id%>">首页


computer110 2004-05-09
  • 打赏
  • 举报
回复
下面是我自己写的page函数,在class页行得通,为什么在nclass就不行了呢
<tr align="center" valign="middle">
<td width="303" height="18"> 共: <font color=#ff3333><%=TotalPage%></font> 页 | 当前: 第 <font color=#ff3333><%=PageNo%></font> 页</td>
<td width="436"> <div align="right">
<%set rs01=server.createobject("adodb.recordset")
sql01="select * from nclass"
rs01.open sql01,conn,1,3
set rs04=server.CreateObject("adodb.recordset")
sql04="select * from news where nclass_id="&rs01("nclass_id")&" "
rs04.open sql04,conn,1,3%>
<%If rs.RecordCount = 0 or TotalPage = 1 Then
Response.Write "当前只有一页"
Else%>
<a href="<%=fileName%>?Class_id=<%=rs04("nclass_id")%>&PageNo=1">首
页</a> |
<%If PageNo - 1 = 0 Then
Response.Write "上一页|"
Else%>
<a href="<%=fileName%>?Class_id=<%=rs04("nclass_id")%>&PageNo=<%=PageNo-1%>">上一页</a>
|
<%End If

If PageNo+1 > TotalPage Then
Response.Write " "
Else%>
<a href="<%=fileName%>?Class_id=<%=rs04("nclass_id")%>&PageNo=<%=PageNo+1%>">下一页</a>
|
<%End If%>
<a href="<%=fileName%>?Class_id=<%=rs04("nclass_id")%>&PageNo=<%=TotalPage%>">末
页</a>
<%End If%>
</div></td>
<td width="47"> </td>
</tr>
</table>
computer110 2004-05-07
  • 打赏
  • 举报
回复
<form actin="page.asp" name="form1" method="post">
<input type="hidden" name="class_id" value="<%=class_id%>">
<table width='100%' border=0 cellpadding="0" cellspacing="0">
<tr align="center" valign="middle">
<td width="303" height="18"> 共: <font color=#ff3333><%=TotalPage%></font> 页 | 当前: 第 <font color=#ff3333><%=PageNo%></font> 页</td>
<td width="436"> <div align="right">
<%If rs.RecordCount = 0 or TotalPage = 1 Then
Response.Write "当前只有一页"
Else%>
<a href="<%=fileName%>?PageNo=1">首
页</a> |
<%If PageNo - 1 = 0 Then
Response.Write "上一页|"
Else%>
<a href="<%=fileName%>?PageNo=<%=PageNo-1%>">上一页</a>
|
<%End If

If PageNo+1 > TotalPage Then
Response.Write " "
Else%>
<a href="<%=fileName%>?PageNo=<%=PageNo+1%>">下一页</a>
|
<%End If%>
<a href="<%=fileName%>?PageNo=<%=TotalPage%>">末
页</a>
<%End If%>
</div></td>
<td width="47"> </td>
</tr>
</table>
</form>
还是和以前一样,我用最笨的方法还是实现了,就是从创建两个adodb.recordset.
我在PageNo加了一个class_id,就可以了.

不知道,用你这种方法要怎么做,

tjficcbw 2004-05-07
  • 打赏
  • 举报
回复
调用的函数,search_page.asp函数改成如下方可。


<table width='100%' border=0 cellpadding="0" cellspacing="0">
<tr align="center" valign="middle">
<td width="303" height="18"> 共: <font color=#ff3333><%=TotalPage%></font> 页 | 当前: 第 <font color=#ff3333><%=PageNo%></font> 页</td>
<td width="436"> <div align="right">
<%If rs.RecordCount = 0 or TotalPage = 1 Then
Response.Write "当前只有一页"
Else%>
<a href="<%=fileName%>?class_id=1<%=hrefdate%>">首
页</a> |
<%If PageNo - 1 = 0 Then
Response.Write "上一页|"
Else%>
<a href="<%=fileName%>?class_id=<%=PageNo-1%><%=hrefdate%>">上一页</a>
|
<%End If

If PageNo+1 > TotalPage Then
Response.Write " "
Else%>
<a href="<%=fileName%>?class_id=<%=PageNo+1%><%=hrefdate%>">下一页</a>
|
<%End If%>
<a href="<%=fileName%>?class_id=<%=TotalPage%><%=hrefdate%>">末
页</a>
<%End If%>
</div></td>
<td width="47"> </td>
</tr>
</table>
rainjue 2004-05-07
  • 打赏
  • 举报
回复
按你的这种写法,应该在每一个超连接后添加变量参数
比如,上一页的连接应该为<a href="<%=fileName%>?PageNo=<%=PageNo-1%><%=hrefdate%>&class_id=<%=class_id%>">
rainjue 2004-05-07
  • 打赏
  • 举报
回复
在你的ASP代码页中需要class_id变量
而你的下一页按钮中一定没有对这个参数进行传递
你的“下一页”应该包含在include文件中吧,那你在下一页的同一表单里添加如下语句:
<input type="hidden" name="class_id" value="<%=class_id%>">
这样应该就不会出现无法显示类别的问题了
computer110 2004-05-07
  • 打赏
  • 举报
回复
下一页的链接,我是调用的函数,search_page.asp函数,这个函数,在我的后台程序里调用了,是对的,没有问题


<table width='100%' border=0 cellpadding="0" cellspacing="0">
<tr align="center" valign="middle">
<td width="303" height="18"> 共: <font color=#ff3333><%=TotalPage%></font> 页 | 当前: 第 <font color=#ff3333><%=PageNo%></font> 页</td>
<td width="436"> <div align="right">
<%If rs.RecordCount = 0 or TotalPage = 1 Then
Response.Write "当前只有一页"
Else%>
<a href="<%=fileName%>?PageNo=1<%=hrefdate%>">首
页</a> |
<%If PageNo - 1 = 0 Then
Response.Write "上一页|"
Else%>
<a href="<%=fileName%>?PageNo=<%=PageNo-1%><%=hrefdate%>">上一页</a>
|
<%End If

If PageNo+1 > TotalPage Then
Response.Write " "
Else%>
<a href="<%=fileName%>?PageNo=<%=PageNo+1%><%=hrefdate%>">下一页</a>
|
<%End If%>
<a href="<%=fileName%>?PageNo=<%=TotalPage%><%=hrefdate%>">末
页</a>
<%End If%>
</div></td>
<td width="47"> </td>
</tr>
</table>
stayhere 2004-05-07
  • 打赏
  • 举报
回复
其他的我没细看,但看下面的代码:
<!--#include file="../hongli/inc/conn.asp"-->

<%
class_id=request("class_id")
if class_id="" then
response.write("<br>"&"<p>")
Response.Write "<center>无相关文章分类!</center>"
response.write "<br>"
response.write "<center><a href=./index.asp>请按这儿返回</a></center>"
Response.End
else%>
....这说明要想显示内容起码得提交class_id方可
而如果仅是'http://localhost/hongli/Class.asp?PageNo=2'这样的链接肯定是会出现所说的情况的.
奇怪的是,我略览了一下,没发现有什么"下一页"的链接处,也没找到任何一个FORM,那这个class_id是从哪里来的呢?
computer110 2004-05-07
  • 打赏
  • 举报
回复
晕,有人不,是什么原因呀

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧