广元灏明园:在查询中分页问题 高手进

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/02 01:34:10
<%
i=1
search=request.form("search")
Set rs=Server.CreateObject("ADODB.RecordSet")
if search<>"" then
sql="select * from server where content like '%" & search & "%' order by id desc"
rs.Open sql,conn,1,1
if not isempty(request("page")) then
pagecount=cint(request("page"))
else
pagecount=1
end if
rs.pagesize=7
rs.AbsolutePage=pagecount

if rs.eof then
%>
<table width="90%" border="0" align="center" cellpadding=0 cellspacing=0>
<tr><td align=center><%response.write "对不起,数据库中没有相关内容!"%></td></tr>
</table>

<%
else
%>
<table width="90%" border="0" align="center" cellpadding=0 cellspacing=0 >
<%
do while not rs.eof%>
<tr>
<td >■   <a href="xianshi.asp?id=<% =rs("id" ) %>" target="_blank"><%=rs("question")%></a><br><br></td></tr>
<%
rs.movenext
if i>=rs.pagesize then exit do
i=i+1
loop
%>

</table>
<p><table width="100%" border="0" cellpadding="0" cellspacing="0" >
<form name="pageform" method="post" action="">
<tr>
<td width="500" align="left">    每页 <font color="#FF0088"><%=rs.pagesize%></font> 条记录 共有 <font color="#FF0088"><%=rs.recordcount%></font> 条记录 共 <font color="#FF0088"><%=rs.pagecount%></font> 页

<% if pagecount=1 and rs.pagecount<>pagecount and rs.pagecount<>0 then
%>| 第一页 |上一页 |
<a href="?page=<%=cstr(pagecount+1)%>">下一页</a> |
<a href="searchnews.asp?page=<%=rs.pagecount%>">最后页</a>
<% end if %>
<% if rs.pagecount>1 and rs.pagecount=pagecount then %>
<a href="searchnews.asp?page=1">| 第一页</a> |
<a href="?page=<%=cstr(pagecount-1)%>">上一页</a> | 下一页 |最后一页
<%end if%>
<% if pagecount<>1 and rs.pagecount<>pagecount then%>
<a href="searchnews.asp?page=1">| 第一页</a> |
<a href="?page=<%=cstr(pagecount-1)%>">上一页</a> | <a href="?page=<%=cstr(pagecount+1)%>">下一页</a> |
<a href="searchnews.asp?page=<%=rs.pagecount%>">最后页</a>
<% end if%>

</td>
</tr>
<tr>
<td>    </td>
</tr>
</form>
</table>
<%
end if
%>
<%
else
response.write "您没有填写关键字!"
end if
%>

</td></tr>

</table>
</td></tr>
</table>

</table>

点下一页的时候老出错,哪个大哥能帮我修改一下
点 下一页的时候,页面显示您“没有填写关键字!”

<a href="?page=<%=cstr(pagecount+1)%>">下一页</a>

应该是<a href="searchnews.asp?page=<%=cstr(pagecount+1)%>">下一页</a> 吧,不然链接里没有具体的页面啊。

<a href="searchnews.asp?NewsID=<%=NewsID%>&page=<%=cstr(pagecount+1)%>">

传值的时候找不到SQL语句了,把sql="select * from server where content like '%" & search & "%' order by id desc"
写成session("sql")="select * from server where content like '%" & search & "%' order by id desc"