标题:[求助]asp查询翻页问题(后续)
只看楼主
yjm239
Rank: 1
等 级:新手上路
帖 子:77
专家分:0
注 册:2006-8-31
 问题点数:0 回复次数:5 
[求助]asp查询翻页问题(后续)

<!--#include file="conn.asp"-->
<!--#include file="./inc/head.asp"-->
<!--#include file="./inc/const.asp"-->
<!--#include file="./inc/char.asp"-->
<table width="100%" border="0" cellspacing="3" cellpadding="3"><tr><td height="20">当前位置:<a href=main.asp>管理首页</a> >> <a href=search.asp>文章搜索</a></td></tr></table>

<%if request("keyword")="" then%>
<script language=javascript>
alert( "错误:请输入关键字!" );
location.href = "javascript:history.back()"
</script>
<%else%>
<table width="95%" cellspacing="1" cellpadding="5" bgcolor="#999999" align="center">
<tr bgcolor=#cccccc><td colspan=8><center><b>搜索 <font color=red><%=request("keyword")%></font> 结果</td></tr>
<tr bgcolor=#ffffff><td height=25 colspan=8></td></tr>
<tr bgcolor=#ffcc00 align=center><td width=2%></td><td width=48%><b>文章标题</td><td width=12%><b>发表时间</td><td width=8%><b>作 者</td><td width=5%><b>头条</td><td width=5%><b>焦点</td><td width=5%><b>图片</td><td width=15%><b>操作</td></tr>
<%
keyword=trim(request("keyword"))
dim searchday
if request("DateSearch")="all" then
searchDay=""
else
searchDay=" DATEDIFF('d',addtime,Now()) < "&request("DateSearch")&" and "
end if

dim pagecount,page,Spage,Epage,recordcount,i
page = request.querystring("page")
if page = "" or IsNull(page) then page = 1
if not IsNumeric(page) then page = 1
page = Cint(page)
set rs = server.CreateObject ("Adodb.recordset")
if request("AreaSearch")=1 then
sql="select * from article where "& searchday &" (" & translate(keyword,"title") & ") order by id desc"
elseif request("AreaSearch")=2 then
sql="select * from article where "& searchday &" (" & translate(keyword,"content") & ") order by id desc"
end if
rs.open sql,conn,1,1
recordcount = RS.RecordCount
RS.PageSize = PAGESIZE
pagecount = RS.PageCount
if page < 1 then
page = 1
elseif page > pagecount then
page = pagecount
end if
if RS.EOF then
Response.Write("<tr bgcolor=#ffffff><td colspan=8 height=20><center><br><font color=red>没有搜索到任何结果!</font></td></tr>")
else
if recordcount > 0 then RS.AbsolutePage = page
for i = 1 to PAGESIZE
if RS.EOF then exit for
%>

<tr bgcolor=#eeeeee>
<td bgcolor=#ffffff><img src=./img/folder.gif></td>
<td><a class=list href=../html/<%=rs("fpath")%>/<%=rs("fname")%> target=_blank><%=HTMLencode(rs("title"))%></a> <font color=#666666>(<%=len(rs("content"))%>字节)</td>
<td><center><%=rs("addtime")%></td>
<td><center><a href=admin_userinfo.asp?username=<%=rs("username")%>><%=rs("username")%></a></td>
<td bgcolor=#dddddd><center><%if session("userkey")=4 then %><%if rs("ifhead")=1 then%><a href=admin_article.asp?action=headno&id=<%=rs("id")%>><font color=red>是</font></a><%else%><a href=admin_article.asp?action=headyes&id=<%=rs("id")%>>否</a><%end if%><%else%><%if rs("ifhead")=1 then%><font color=red>是</font><%else%>否<%end if%><%end if%></td>
<td><center><%if session("userkey")=4 then %><%if rs("ifgood")=1 then%><a href=admin_article.asp?action=goodno&id=<%=rs("id")%>><font color=blue>是</font></a><%else%><a href=admin_article.asp?action=goodyes&id=<%=rs("id")%>>否</a><%end if%><%else%><%if rs("ifgood")=1 then%><font color=blue>是</font><%else%>否<%end if%><%end if%></td>
<td bgcolor=#dddddd><center><%if session("userkey")=4 then %><%if rs("ifimg")=1 then%><a href=admin_article.asp?action=imgno&id=<%=rs("id")%>><font color=green>是</font></a><%else%><a href=admin_article.asp?action=imgyes&id=<%=rs("id")%>>否</a><%end if%><%else%><%if rs("ifimg")=1 then%><font color=red>是</font><%else%>否<%end if%><%end if%></td>

<td><center><%if session("userkey")=4 then %><%if rs("ifshow")=1 then%><a href=admin_article.asp?action=showno&id=<%=rs("id")%>><font color=red>已审</font></a><%else%><a href=admin_article.asp?action=showyes&id=<%=rs("id")%>>待审</a><%end if%><%else%><%if rs("ifshow")=1 then%><font color=red>已审</font><%else%>待审<%end if%><%end if%>
<%if session("userkey")=4 or session("username")=rs("username") then%> | <a href=fastedit.asp?id=<%=rs("id")%>><font color=green>修改</font></a><%end if%>
<%if session("userkey")=4 or session("username")=rs("username") then%> | <a href=admin_article.asp?action=delarticle&id=<%=rs("id")%>><font color=blue>删除</font></a><%end if%></td>
</tr>
<%
RS.MoveNext()
next
end if
%>
</table>

<%
if pagecount > 0 then
response.write("<table width=""95%"" align=center cellspacing=3 cellpadding=3><tr><td align=right>")
response.write("页次:<font color=red><b>" & page & "</font>/" & pagecount & "</b>&nbsp;&nbsp;每页<b>" & pagesize & "</b>&nbsp;&nbsp;共<b>" & recordcount & "</b>篇文章&nbsp;&nbsp;分页:")
Spage = page mod PARTSIZE
if page > PARTSIZE then
if Spage = 0 then Spage = PARTSIZE
Spage = page - Spage + 1
else
Spage = 1
end if
Epage = Spage + PARTSIZE - 1
if Epage > pagecount then Epage = pagecount
if page > PARTSIZE then
response.write("<a href=""searchresult.asp?page=" & Spage - 1 & """>[<<]</a>")
end if
for i = Spage to Epage
if i = page then
response.write("[<font color=red><b>" & i & "</b></font>]")
else
response.write("[<a href=""searchresult.asp?page=" & i & """>" & i & "</a>]")
end if
next
if Epage < pagecount then
response.write("<a href=""searchresult.asp?page=" & Epage + 1 & """>[>>]</a>")
end if
if Spage <> 1 then response.write("[<a href=""searchresult.asp?page=1"">首页</a>]")
if Epage <> pagecount then response.write("[<a href=""searchresult.asp?page=" & pagecount & """>尾页</a>]")
response.write("</td></tr></table><br>")
end if
rs.close
set rs=nothing
%>


<%end if%>

<!--#include file="./inc/end.asp"-->


上面代码,翻页总是提示,请输入关键字?
请问如何解决呢。。

[此贴子已经被作者于2006-12-18 14:56:15编辑过]

搜索更多相关主题的帖子: asp include file href 
2006-12-18 14:54
做人很低调
Rank: 5Rank: 5
等 级:贵宾
威 望:18
帖 子:1268
专家分:0
注 册:2006-8-2
得分:0 
你写的连接没有传参数
keyword


如这样
<a href="?page=1&keyword=<%=keyword%>">首页</a>

其实我很低调,只是你不知道...
2006-12-18 15:20
yjm239
Rank: 1
等 级:新手上路
帖 子:77
专家分:0
注 册:2006-8-31
得分:0 
加入后提示
未结束的字符串常量
2006-12-18 15:29
hangxj
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:2045
专家分:0
注 册:2006-4-10
得分:0 
<a href='?page=1&keyword="&keyword&"'>首页</a>

或者

<a href=""?page=1&keyword="&keyword&""">首页</a>


人家给了你,你要自己去想.


http://www./
2006-12-18 16:16
yjm239
Rank: 1
等 级:新手上路
帖 子:77
专家分:0
注 册:2006-8-31
得分:0 
问题找到了,我就是<a href=""?page=1&keyword="&keyword&""">首页</a>

这么写的,其实问题在于上面areasearch的值并没有传递
2006-12-18 16:19
yjm239
Rank: 1
等 级:新手上路
帖 子:77
专家分:0
注 册:2006-8-31
得分:0 
翻页问题是解决了,但是查询出来的记录,选择是、否及已审,删除操作都会提示“请输入关键字”,但是操作是执行了。
我在语句中加入<td bgcolor=#dddddd><center><%if session("userkey")=4 then %><%if rs("ifhead")=1 then%><a href=admin_article.asp?action=headno&id=<%=rs("id")%>&keyword=<%=keyword%>&AreaSearch=<%=AreaSearch%>><font color=red>是</font></a><%else%><a href=admin_article.asp?action=headyes&id=<%=rs("id")%>&keyword=<%=keyword%>&AreaSearch=<%=AreaSearch%>>否</a><%end if%><%else%><%if rs("ifhead")=1 then%><font color=red>是</font><%else%>否<%end if%><%end if%></td>
也传递参数了
2006-12-26 08:11



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-110284-1-1.html




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

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