紧急求救!!我的分页显示数失效了! 请高手帮忙.......

lxp1314yzp 2003-04-29 11:25:02
if tj<>"" then'**************
sqlstr="select * from qianzheng " & tj
'分页
scriptname=Request.ServerVariables("script_name")
mypage=Request.QueryString("whichpage")
if mypage="" then
mypage=1
end if
mypagesize=10
'*********

set rss1=server.CreateObject("adodb.recordset")
rss1.Open sqlstr,conn,1,3
if rss1.RecordCount >0 then
'******
rss1.CacheSize =10
if not rss1.EOF then
rss1.MoveFirst
rss1.PageSize =mypagesize
maxcount=cint(rss1.PageCount )
rss1.AbsolutePage =mypage
end if
count=0
do while not rss1.EOF and count<rss1.PageSize %>

'显示数据区

<%rss1.MoveNext
count=count+1
loop
else
Response.Write "没有找到合适的纪录!"
end if
rss1.Close
set rss1=nothing
end if
%>
</table>
<center><%Response.Write "<font size=2>共"& maxcount &"页 第" & mypage & "页</font>" %></center>
<center>
<%for i=1 to maxcount
Response.Write " <a href='"& scriptname &"?whichpage="& i &"'><font size=2>"& i & "</font></a> "
if i mod 20 =0 then
Response.Write "<br>"
end if
next

当我点击其它页时不显示数据,原因已经找到,就是我用到的变量“tj”提交时已为空,更让我奇怪的是在这里session变量也失效(点其它页时也变为空了)

问题:如何解决变量的数值保存!(变量“tj”)
请大虾帮帮忙,紧急求救!!!!!
...全文
85 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
cqfeng 2003-04-29
  • 打赏
  • 举报
回复
;<a href='"& scriptname &"?tj=<%=tj%>&whichpage="& i &"'><font size=2>"& i & "</font></a>&
netnight 2003-04-29
  • 打赏
  • 举报
回复
分页的时候要把text里的参数传过去,所以在分页的链接里要传过去参数
如:Response.Write"<A href=index.asp?page=page+1"&"hyname="&hyname&"hytime="&hytime&">下一页</A>"
快下班,没仔细看你的代码:)
是这个问题不,供参考
960379 2003-04-29
  • 打赏
  • 举报
回复
你把用来确定 tj的input放在form里面对吧。当每一次点击上一页或者下一页的时候,页面都会刷新一次,那么input里面的内容会改变,你的sql语句也会跟着改变。
如果一定要采用这种方法的话,你必须保证在每一次刷新页面的时候input(或者select)里面的内容 不变。
这种方法很不好。不过我也找不到其他的好办法。
lxp1314yzp 2003-04-29
  • 打赏
  • 举报
回复
if trim(request("text1"))<>"" then
tj="where 单位号='"& trim(request("text1"))&"'"
if trim(request("text2"))<>"" then
tj=tj & " and 姓名 like '%"& trim(request("text2")) &"%'"
end if
else
if trim(request("text2"))<>"" then
tj="where 姓名 like '%"& trim(request("text2")) &"%'"
end if
end if
'*****以下接我提问时的代码
if tj<>"" then
sqlstr="select * from qianzheng " & tj
...........
请大家帮个忙,这个小问题困扰我好几天了,谢谢了!!
stormhu 2003-04-29
  • 打赏
  • 举报
回复
没说明白 tj 是个什么样的变量
lxp1314yzp 2003-04-29
  • 打赏
  • 举报
回复
to: coolnick(林息)

你的代码很正确,但是有一点和我不同:

sql="Select * From Table1 Where type='manager'"
你的条件"Where type='manager'"中的"manager"是个常量,而我的(tj)是一个变量,需要在点其它页时能够记住它的值.

如果你把"manager"变成用户可输入的值(text框形式),就会出现和我一样的错误!!

caoqizi 2003-04-29
  • 打赏
  • 举报
回复
我同意 coolnick(林息)的代码。帮UP
shan__le 2003-04-29
  • 打赏
  • 举报
回复
传参数好了,怎么读取session的值呢?
coolnick 2003-04-29
  • 打赏
  • 举报
回复
下面的代码是我以前实现的分页功能,一点问题也没有,
你分析分析吧。

//main.asp
<% Const adOpenStatic = 3 %>
<!--#include file="OnePage.asp"-->
<!--#include file="OpenObject.asp"-->
<!--#include file="ShowMenu.asp"-->
<%
Set conn=OpenOrGet_Database("stock_conn")
Set rs=Server.CreateObject("ADODB.Recordset")
sql="Select * From Table1 Where type='manager'"
rs.Open sql,conn,adOpenStatic
%>

<center><font size=6 color="#0000ff"><b>行政管理文件信息</b></font></center><p>
<font size=4 color=#ff0000>注意:如果没有看到你刚输入的信息,则刷新此页面!</font><br>
<%
Page=CLng(Request("Page"))
if Page<1 then
Page=1
End If
if Page>rs.PageCount then
Page=rs.PageCount
End If
%>

<%
If rs.RecordCount=0 Then
Response.Write "<font size=4 color=#ff0000>此目录暂无记录</font>"
Else
ShowOnePage rs,Page
ShowMenu
End If
%>
<%
Response.Write "<body background='bkgnd.jpg'>"
Response.Write "</body>"
%>

//OnePage.asp
<%
Sub ShowOnePage(rs,Page)
Response.Write "<center><table border=1>"
Response.Write "<TR bgcolor='#00ffff'>"
Response.Write "<td align=center>序号</td>"
for i=1 to rs.Fields.Count-1
Response.write "<TD align=center>" & rs.Fields(i).Name & "</td>"
Next
Response.write "</tr>"
rs.AbsolutePage=Page
for iPage=1 to rs.PageSize
Response.Write "<TR>"
RecNo=(Page-1)*rs.PageSize+iPage
Response.Write "<td>" & RecNo & "</td>"
for i=1 to rs.Fields.Count-1
Response.Write "<td>" & rs.Fields(i).Value & "</td>"
Next
Response.Write "</tr>"
rs.MoveNext
if rs.EOF Then Exit for
Next
Response.Write "</table></center>"
End Sub
%>

//ShowMenu.asp
<!--#include file="DirectFile.asp" -->
<script language="JavaScript">
function Validate1()
{
if(document.form1.Page.value=="")
{
alert("你还没有输入页码呢!");
return false;
}
return true;
}
</script>
<%
Sub ShowMenu()
%>
<form action="main.asp" method=post name=form1 onSubmit="return Validate1();">
<font color="red">
<center>
<% if Page<>1 then %>
<a href="main.asp?Page=1">第一页</a>"
   
<a href="main.asp?Page=<% =(Page-1) %>">上一页</a>
   
<% End If %>
<% if Page<>rs.PageCount Then %>
<a href="main.asp?Page=<% =(Page+1) %>">下一页</a>
   
<a href="main.asp?Page=<% =rs.PageCount %>">最后一页</a>
   
<% End If %>
输入页码:<input type=text name=Page size=3><input type=submit value="GO">
  页码:<% =Page %>/<% =rs.PageCount %>
</center>
</font>
</form>
<% End Sub %>

28,409

社区成员

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

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