asp分页显示 第一页显示正常,点击到下一页也正常,可是从下一页点击就显示不正常,说无记录
opdb.asp<%session("database")="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Server.M...
opdb.asp
<%session("database")= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("dbase/demodata.asp")
set conn=Server.CreateObject("adodb.connection")
conn.open session("database")%>
首页
<!--#include file="openDB.asp"-->
ul>
<%set rst = server.CreateObject("adodb.recordset")
strsql = "select * from news where Username = '招商引资' order by ntime desc"
rst.open strsql,conn
if rst.eof then
response.Write " 暂时无内容"
else
do while not rst.eof
%>
<li><a href="erji.asp?Nt='<%=rst("Ntype")%>'"><%=rst("Ntype")%></a></li> <%
rst.MoveNext
loop
rst.Close
end if%></ul>
erji.asp 分页
<table width="670" height="360" border="0" cellpadding="0" cellspacing="0" class="lianxi"> <tr>
<td valign="top">
<%
if request("Nt")<>"" then
session("Ntype")=request("Nt")
Nt=request.QueryString("Nt")
end if
set rst = server.CreateObject("adodb.recordset")
strsql = "select * from news where Ntype="&session("Ntype")&""
rst.open strsql,conn,1,1
if rst.recordcount=0 then
response.Write " 暂时无内容"
end if
page=cint(request.QueryString("page"))
rst.pagesize=10
if page<=0 then page=1
rst.absolutepage=page
pagesize=rst.pagesize
for i=1 to pagesize
%>
<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr class="lianxi"><td width="5%" height="30" align="center"><img src="imges/em-7.gif" width="10" height="9" /></td> <td width="80%">
<a href="jshow.asp?id=<%=rst("id")%>" id="3a"><%=left(rst("ntitle"),25)%>
<%if len(rst("ntitle")) > 25 then%> ...<%end if%></a>
</td><td width="15%">
<%=year(rst("ntime"))%>-<%=month(rst("ntime"))%>-<%=day(rst("ntime"))%></td></tr></table>
<% rst.movenext
if rst.eof then exit for
next%>
<table><tr><td colspan="7" align="center" valign="middle" class="STYLE15">
<% if page<>1 then%>
<a href="erji.asp?page=1&Nt='<%=(rst("Ntype"))%>'">首页</a>
<a href="erji.asp?page=<%=page-1%>&Nt='<%=(rst("Ntype"))%>'">上一页</a>
<%end if%>
<% if page<>rst.pagecount then%>
<a href="erji.asp?page=<%=page+1%>&Nt='<%=(rst("Ntype"))%>'">下一页</a>
<a href="erji.asp?page=<%=rst.pagecount%>&Nt='<%=(rst("Ntype"))%>'">末页</a>
<%end if%>
当前第<%=page%>页 共<%=rst.pagecount%>页
<select name="xuanze1" onchange="xuanze()">
<% for i=1 to rst.pagecount%>
<option value="erji.asp?page=<%=i%>&Nt='<%=(rst("Ntype"))%>'" <%if page=i then%>selected<%end if%>>第<%=i%>页</option>
<%next%>
</select>
<script language="vbscript">
sub xuanze()
document.location=xuanze1.value
end sub
</script>
<%On error resume next%>
</td></tr> </table></td></tr></table>
我点击下页后,再点回去,Ntype...没有值
我是菜鸟,等这个很焦急,就这些分全给了啊,大哥们帮帮啊,
我是直接用超连结传递值与表单搜索没有关联啊,页面数是根据列数生成多少页,我的意思是说即使是2页,当我点击进入第二页后,再点击上一页,就没有传递值,大哥们,我很焦急啊,在线等 展开
<%session("database")= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("dbase/demodata.asp")
set conn=Server.CreateObject("adodb.connection")
conn.open session("database")%>
首页
<!--#include file="openDB.asp"-->
ul>
<%set rst = server.CreateObject("adodb.recordset")
strsql = "select * from news where Username = '招商引资' order by ntime desc"
rst.open strsql,conn
if rst.eof then
response.Write " 暂时无内容"
else
do while not rst.eof
%>
<li><a href="erji.asp?Nt='<%=rst("Ntype")%>'"><%=rst("Ntype")%></a></li> <%
rst.MoveNext
loop
rst.Close
end if%></ul>
erji.asp 分页
<table width="670" height="360" border="0" cellpadding="0" cellspacing="0" class="lianxi"> <tr>
<td valign="top">
<%
if request("Nt")<>"" then
session("Ntype")=request("Nt")
Nt=request.QueryString("Nt")
end if
set rst = server.CreateObject("adodb.recordset")
strsql = "select * from news where Ntype="&session("Ntype")&""
rst.open strsql,conn,1,1
if rst.recordcount=0 then
response.Write " 暂时无内容"
end if
page=cint(request.QueryString("page"))
rst.pagesize=10
if page<=0 then page=1
rst.absolutepage=page
pagesize=rst.pagesize
for i=1 to pagesize
%>
<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr class="lianxi"><td width="5%" height="30" align="center"><img src="imges/em-7.gif" width="10" height="9" /></td> <td width="80%">
<a href="jshow.asp?id=<%=rst("id")%>" id="3a"><%=left(rst("ntitle"),25)%>
<%if len(rst("ntitle")) > 25 then%> ...<%end if%></a>
</td><td width="15%">
<%=year(rst("ntime"))%>-<%=month(rst("ntime"))%>-<%=day(rst("ntime"))%></td></tr></table>
<% rst.movenext
if rst.eof then exit for
next%>
<table><tr><td colspan="7" align="center" valign="middle" class="STYLE15">
<% if page<>1 then%>
<a href="erji.asp?page=1&Nt='<%=(rst("Ntype"))%>'">首页</a>
<a href="erji.asp?page=<%=page-1%>&Nt='<%=(rst("Ntype"))%>'">上一页</a>
<%end if%>
<% if page<>rst.pagecount then%>
<a href="erji.asp?page=<%=page+1%>&Nt='<%=(rst("Ntype"))%>'">下一页</a>
<a href="erji.asp?page=<%=rst.pagecount%>&Nt='<%=(rst("Ntype"))%>'">末页</a>
<%end if%>
当前第<%=page%>页 共<%=rst.pagecount%>页
<select name="xuanze1" onchange="xuanze()">
<% for i=1 to rst.pagecount%>
<option value="erji.asp?page=<%=i%>&Nt='<%=(rst("Ntype"))%>'" <%if page=i then%>selected<%end if%>>第<%=i%>页</option>
<%next%>
</select>
<script language="vbscript">
sub xuanze()
document.location=xuanze1.value
end sub
</script>
<%On error resume next%>
</td></tr> </table></td></tr></table>
我点击下页后,再点回去,Ntype...没有值
我是菜鸟,等这个很焦急,就这些分全给了啊,大哥们帮帮啊,
我是直接用超连结传递值与表单搜索没有关联啊,页面数是根据列数生成多少页,我的意思是说即使是2页,当我点击进入第二页后,再点击上一页,就没有传递值,大哥们,我很焦急啊,在线等 展开
4个回答
展开全部
建立access的数据库news,还有表news,表的字段(id,title),id唯一,输入数据保存,用下面代码可查询,可分页
-----------------------下面保存为search.asp--------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>文件</title>
</head>
<body bgcolor="#ffffff">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<script>
function btn_ck_bh_Click()
{
var cx = document.form1.cxsj.value;
form1.action ="search.asp?cx="+cx;
}
</script>
<table border="1" cellspacing="0" bgcolor="#F0F8FF" bordercolorlight="#4DA6FF" bordercolordark="#ECF5FF" width="88%" style="word-break:break-all">
<tr>
<td width="778" align="center" colspan="7">
<form method="POST" name="form1" action=search.asp>
<p>输入搜索内容:<input type="text" name="cxsj" size="20"><input type="submit" value="提交" name="B1" LANGUAGE="javascript" onclick="btn_ck_bh_Click()">
<input type="reset" value="重写" name="B2"></p>
</form>
</td>
</tr>
</table>
<table border="1" cellspacing="0" bgcolor="#F0F8FF" bordercolorlight="#4DA6FF" bordercolordark="#ECF5FF" width="88%" style="word-break:break-all">
<tr>
<td width="8%" align="center"><strong><font color="#0080C0">ID 号</font></strong></td>
<td width="58%" align="center"><strong><font color="#0080C0">标 题</font></strong></td>
<td width="8%" align="center"><strong><font color="#0080C0">修 改</font></strong></td>
<td width="8%" align="center"><strong><font color="#0080C0">删 除</font></strong></td>
</tr>
<%
'数据库查询
'获得搜索内容
cx = request("cx")
dim pageCount
'把page转换成整数
page = cint(request("page"))
set conn=server.createobject("adodb.connection")'
set rs=server.createobject("adodb.recordset")
conn.open "DBQ=" & server.mappath("./news.mdb") & ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
' 获取产品的名字记录集(从 news表中)
if cx <> "" then
sql = "select * from news where title like '%"&cx& "%' order by id desc"
else
sql ="select * from news order by id desc"
end if
rs.open sql,conn,3,3
'如果没有数据记录
if rs.bof then
errmsg=errmsg+"<br>"+"<li>"+keyword+"没有记录,请返回!!"
response.write errmsg
response.end
end if
' 设置记录集在每页的总行数,也就是 PageSize属性
RS.PageSize=40
'把rs.pageCount转换成整数和page才能作比较
pageCount = cint(rs.pageCount)
' 设置当前的页号( AbsolutePage属性)
if page = 0 then
page =1
end if
RS.AbsolutePage = page
x=1
' 显示当前页中的所有记录( PageSize中设置的行数)
WHILE NOT RS.EOF AND NumRows<RS.PageSize
%>
<tr onmouseover="this.bgColor='#99ccff'" onmouseout="this.bgColor=''">
<td width="8%"><p align="center"><%=rs("id")%></td>
<td width="58%"><a href="view.asp?id=<%=rs("id")%>" target="_blank"><%=rs("title")%></a></td>
<td width="8%" align="center"><a href="edit.asp?id="<%=rs("id")%>>修 改</a></td>
<td width="8%" align="center"><a href="delet.asp?id="<%=rs("id")%>>删 除</a></td>
</tr>
<%RS.MoveNext
NumRows=NumRows+1
WEND%>
<tr onmouseover="this.bgColor='#99ccff'" onmouseout="this.bgColor=''">
<td width="105%" align="center" colspan="6"> </td> </tr>
<tr>
<td width="105%" align="center" colspan="6">
<p align="center"><FONT color=#333333>共<%=PageCount%>页 第<%=page%>页★
<%if page=1 then%>首页<%end if%>
<%if page>1 then%>
<A HREF="search.asp?page=1&cx=<%=cx%>"> 首页</A>
<%end if%>★
<%if page>1 then%><A HREF="search.asp?page=<%=page-1%>&cx=<%=cx%>"><%end if%>上一页</a>
<%
dim pagewhere
dim p
p = 1
'把pagewhere转换成整数
'pagewhere = cint(request("pagewhere"))
pagewhere = pageCount
if pagewhere>0 then
for p=1 to pagewhere
if p <> page then%>
<A HREF="search.asp?page=<%=p%>&cx=<%=cx%>"><%=p%></a>
<%end if
if p =page then%>
<%=p%>
<% end if
next
end if%>
<%if page < PageCount then%>
<A HREF="search.asp?page=<%=page+1%>&cx=<%=cx%>">
<%end if %>下一页</A>★
<%if page=PageCount then%>尾页
<%end if%>
<%if page<PageCount then%>
<A HREF="search.asp?page=<%=PageCount%>&cx=<%=cx%>"> 尾页</A>
<%end if%>
</p></FONT></td> </tr> <tr>
<td width="105%" align="center" colspan="6">搜索内容:<%=cx%></td>
</tr>
</table></center></div>
</body></html>
<%
rs.close
Set rs=nothing
conn.close
set conn=nothing
%>
-----------------------下面保存为search.asp--------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>文件</title>
</head>
<body bgcolor="#ffffff">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<script>
function btn_ck_bh_Click()
{
var cx = document.form1.cxsj.value;
form1.action ="search.asp?cx="+cx;
}
</script>
<table border="1" cellspacing="0" bgcolor="#F0F8FF" bordercolorlight="#4DA6FF" bordercolordark="#ECF5FF" width="88%" style="word-break:break-all">
<tr>
<td width="778" align="center" colspan="7">
<form method="POST" name="form1" action=search.asp>
<p>输入搜索内容:<input type="text" name="cxsj" size="20"><input type="submit" value="提交" name="B1" LANGUAGE="javascript" onclick="btn_ck_bh_Click()">
<input type="reset" value="重写" name="B2"></p>
</form>
</td>
</tr>
</table>
<table border="1" cellspacing="0" bgcolor="#F0F8FF" bordercolorlight="#4DA6FF" bordercolordark="#ECF5FF" width="88%" style="word-break:break-all">
<tr>
<td width="8%" align="center"><strong><font color="#0080C0">ID 号</font></strong></td>
<td width="58%" align="center"><strong><font color="#0080C0">标 题</font></strong></td>
<td width="8%" align="center"><strong><font color="#0080C0">修 改</font></strong></td>
<td width="8%" align="center"><strong><font color="#0080C0">删 除</font></strong></td>
</tr>
<%
'数据库查询
'获得搜索内容
cx = request("cx")
dim pageCount
'把page转换成整数
page = cint(request("page"))
set conn=server.createobject("adodb.connection")'
set rs=server.createobject("adodb.recordset")
conn.open "DBQ=" & server.mappath("./news.mdb") & ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
' 获取产品的名字记录集(从 news表中)
if cx <> "" then
sql = "select * from news where title like '%"&cx& "%' order by id desc"
else
sql ="select * from news order by id desc"
end if
rs.open sql,conn,3,3
'如果没有数据记录
if rs.bof then
errmsg=errmsg+"<br>"+"<li>"+keyword+"没有记录,请返回!!"
response.write errmsg
response.end
end if
' 设置记录集在每页的总行数,也就是 PageSize属性
RS.PageSize=40
'把rs.pageCount转换成整数和page才能作比较
pageCount = cint(rs.pageCount)
' 设置当前的页号( AbsolutePage属性)
if page = 0 then
page =1
end if
RS.AbsolutePage = page
x=1
' 显示当前页中的所有记录( PageSize中设置的行数)
WHILE NOT RS.EOF AND NumRows<RS.PageSize
%>
<tr onmouseover="this.bgColor='#99ccff'" onmouseout="this.bgColor=''">
<td width="8%"><p align="center"><%=rs("id")%></td>
<td width="58%"><a href="view.asp?id=<%=rs("id")%>" target="_blank"><%=rs("title")%></a></td>
<td width="8%" align="center"><a href="edit.asp?id="<%=rs("id")%>>修 改</a></td>
<td width="8%" align="center"><a href="delet.asp?id="<%=rs("id")%>>删 除</a></td>
</tr>
<%RS.MoveNext
NumRows=NumRows+1
WEND%>
<tr onmouseover="this.bgColor='#99ccff'" onmouseout="this.bgColor=''">
<td width="105%" align="center" colspan="6"> </td> </tr>
<tr>
<td width="105%" align="center" colspan="6">
<p align="center"><FONT color=#333333>共<%=PageCount%>页 第<%=page%>页★
<%if page=1 then%>首页<%end if%>
<%if page>1 then%>
<A HREF="search.asp?page=1&cx=<%=cx%>"> 首页</A>
<%end if%>★
<%if page>1 then%><A HREF="search.asp?page=<%=page-1%>&cx=<%=cx%>"><%end if%>上一页</a>
<%
dim pagewhere
dim p
p = 1
'把pagewhere转换成整数
'pagewhere = cint(request("pagewhere"))
pagewhere = pageCount
if pagewhere>0 then
for p=1 to pagewhere
if p <> page then%>
<A HREF="search.asp?page=<%=p%>&cx=<%=cx%>"><%=p%></a>
<%end if
if p =page then%>
<%=p%>
<% end if
next
end if%>
<%if page < PageCount then%>
<A HREF="search.asp?page=<%=page+1%>&cx=<%=cx%>">
<%end if %>下一页</A>★
<%if page=PageCount then%>尾页
<%end if%>
<%if page<PageCount then%>
<A HREF="search.asp?page=<%=PageCount%>&cx=<%=cx%>"> 尾页</A>
<%end if%>
</p></FONT></td> </tr> <tr>
<td width="105%" align="center" colspan="6">搜索内容:<%=cx%></td>
</tr>
</table></center></div>
</body></html>
<%
rs.close
Set rs=nothing
conn.close
set conn=nothing
%>
展开全部
<%Const MaxPerPage=10%>
<%
dim rs,sql,sqlstr
dim totalPut
dim CurrentPage, TotalPages
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
set rs = server.createobject("adodb.recordset")
%>
<%
sql="select * from detail order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "<p align='center'>没有或没有找到任何软件</p>"
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,"index.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
showContent
showpage totalput,MaxPerPage,"index.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"index.asp"
end if
end if
rs.close
end if
sub showContent
dim i
i=0
%>
<table align="center" border="1" bgcolor="">
<tr>
<td>ID</td>
<td>歌曲名称</td>
<td>歌曲地址A</td>
<td>歌曲地址B</td>
<td>歌曲地址C</td>
<td>歌手名字</td>
<td>歌曲排序</td>
<td>歌曲分类</td>
<td>是否审核</td>
<td>最新播放</td>
<td>播放统计</td>
<td>歌曲报错</td>
</tr>
<%
do while not rs.eof
%>
<tr>
<td><%=rs("ID")%></td>
<td><%=rs("title")%></td>
<td><%=rs("urla")%></td>
<td><%=rs("urlb")%></td>
<td><%=rs("urlc")%></td>
<td><%=rs("memo")%></td>
<td><%=rs("topid")%></td>
<td><%=rs("classid")%></td>
<td><%=rs("verity")%></td>
<td><%=rs("time")%></td>
<td><%=rs("out")%></td>
<td><%=rs("error")%></td>
</tr>
<%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
end sub
%>
</table>
<%
function showpage(totalnumber,maxperpage,filename)
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
response.write "<p align='center'><font color='#000080'> 共有<b>"&totalnumber&"</b>个软件"
if CurrentPage<2 then
response.write ""
else
response.write "<a href="&filename&"?page=1>首页</a> | "
response.write "<a href="&filename&"?page="&CurrentPage-1&">上一页</a> | "
end if
if n-currentpage<1 then
response.write ""
else
response.write "<a href="&filename&"?page="&(CurrentPage+1)&">"
response.write "下一页</a> | <a href="&filename&"?page="&n&">尾页</a>"
end if
response.write "<font color='#000080'> 页次:</font><strong><font color=red>"&CurrentPage&"</font><font color='#000080'>/"&n&"</strong>页</font> "
response.write " <b>"&maxperpage&"</b>个软件/页</font>"
%>
<%
end function
%>
<%
dim rs,sql,sqlstr
dim totalPut
dim CurrentPage, TotalPages
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
set rs = server.createobject("adodb.recordset")
%>
<%
sql="select * from detail order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "<p align='center'>没有或没有找到任何软件</p>"
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,"index.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
showContent
showpage totalput,MaxPerPage,"index.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"index.asp"
end if
end if
rs.close
end if
sub showContent
dim i
i=0
%>
<table align="center" border="1" bgcolor="">
<tr>
<td>ID</td>
<td>歌曲名称</td>
<td>歌曲地址A</td>
<td>歌曲地址B</td>
<td>歌曲地址C</td>
<td>歌手名字</td>
<td>歌曲排序</td>
<td>歌曲分类</td>
<td>是否审核</td>
<td>最新播放</td>
<td>播放统计</td>
<td>歌曲报错</td>
</tr>
<%
do while not rs.eof
%>
<tr>
<td><%=rs("ID")%></td>
<td><%=rs("title")%></td>
<td><%=rs("urla")%></td>
<td><%=rs("urlb")%></td>
<td><%=rs("urlc")%></td>
<td><%=rs("memo")%></td>
<td><%=rs("topid")%></td>
<td><%=rs("classid")%></td>
<td><%=rs("verity")%></td>
<td><%=rs("time")%></td>
<td><%=rs("out")%></td>
<td><%=rs("error")%></td>
</tr>
<%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
end sub
%>
</table>
<%
function showpage(totalnumber,maxperpage,filename)
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
response.write "<p align='center'><font color='#000080'> 共有<b>"&totalnumber&"</b>个软件"
if CurrentPage<2 then
response.write ""
else
response.write "<a href="&filename&"?page=1>首页</a> | "
response.write "<a href="&filename&"?page="&CurrentPage-1&">上一页</a> | "
end if
if n-currentpage<1 then
response.write ""
else
response.write "<a href="&filename&"?page="&(CurrentPage+1)&">"
response.write "下一页</a> | <a href="&filename&"?page="&n&">尾页</a>"
end if
response.write "<font color='#000080'> 页次:</font><strong><font color=red>"&CurrentPage&"</font><font color='#000080'>/"&n&"</strong>页</font> "
response.write " <b>"&maxperpage&"</b>个软件/页</font>"
%>
<%
end function
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<a href="erji.asp?page=<%=page+1%>&Nt='<%=(rst("Ntype"))%>'">下一页</a>
将里面的rst("Ntype")换成NT即可解决即:
<a href="erji.asp?page=<%=page+1%>&Nt='<%=(NT)%>'">下一页</a>
将里面的rst("Ntype")换成NT即可解决即:
<a href="erji.asp?page=<%=page+1%>&Nt='<%=(NT)%>'">下一页</a>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询