困扰我的一个asp的小问题(30分)

F

fly555

Unregistered / Unconfirmed
GUEST, unregistred user!
我用asp做了个动态查询的。
查询结果是分页显示。
当显示符合条件的第一页时,
完全正常。
因为它要根据动态查询的条件生成sql的。
但是当点击第二页时,执行下面四句之后,
<% seek_name=Trim(Request("txt_name"))
seek_xueli=Trim(Request("sel_xueli"))
seek_zhicheng=Trim(Request("sel_zhicheng"))
seek_zhuangkuang=Trim(Request ("sel_zhuangkuang"))
四个seek_... 是取不到值的,结果全为空了,
所以sql语句就产生了变化, 已不是用户最初的选择了。
虚心请教了。
 
如果你的第2页是通过链接来的,在链接参数里加上&amp;txt_name=..&amp;sel_xueli=..&amp;...
如果是通过form方式来提交的,用
<input type=hidden name=txt_name value=>
<input type=hidden name=sel_xueli value=>
...
肯定没问题
 
csz:你是这方面的高手吧。
我做的这个查询文件很小,
可不可以把它发个邮件给你,
你帮我看一下,
好吗?
楼上的,你好!
你的第2页是通过链接来的
原来是这样写的:
<a href='people_seek1.asp?pageno=<%=pno%>'><%=pno%></a></b>
第一页可以.
象你所说的变成下面这样 第一页也打不开了
<a href='people_seek1.asp?pageno=<%=pno%>&amp;txt_name=<%=seek_name>&amp;sel_xueli=<%seek_xueli%>&amp;sel_zhicheng=<%=seek_zhicheng%>&amp;sel_zhuangkuang=<%seek_zhuangkuang%>'><%=pno%></a></b>
运行后出现这个错误,是什么原因?
Microsoft VBScript 编译器错误 错误 '800a03ea'
语法错误
/dtcx/people_seek1.asp, 行257
Response.Write(seek_name>&amp;sel_xueli=<%seek_xueli)
不知怎么回事?
 
Request.QueryString("txt_name")
 
什么意思?
 
乐于助人的高手留个信箱,
我把几个小文件发给你,
帮我看一下,
多谢了。
 
不用发过来了,我知道错误在哪里,你不能把<%..%>的asp语句放在字符串中,你上面就
是把它放到字符串中导致错误<a href='asp语句'>,应该把它改为
<%="<a href='people_seek1.asp?pageno=" &amp;pno &amp;"&amp;txt_name=" &amp;seek_name &amp;"&amp;sel_xueli=" &amp;seek_xueli &amp;"'>" &amp;pno &amp;"</a>"%>
快点试试吧,别忘了给我加分啊。。。呵呵,祝你好运@!
 
上面那位wolaixue兄说的并不是问题所在,Request.QueryString("txt_name")和Request("txt_name")是
一样的,Request("txt_name")是缩写方式。
 
我晕
越看越晕
首先 你需要认真学习ASP的工作流程, 然后理解Form提交的两种方式POST与GET的区别
再决定使用哪种提交方式来处理你的查询。
如果使用GET 你用Request.QueryString来获得参数
如果使用POST 你用Reqeust.FORM来获得参数
建议你可以使用 隐藏字段来保存参数 就像上面 csz 所述
 
>>不用发过来了,我知道错误在哪里,你不能把<%..%>的asp语句放在字符串中,你上面就
是把它放到字符串中导致错误<a href='asp语句'>,应该把它改为
to feichong:我倒~有没搞错,你是这样写asp的?
to fly555:
改成:<a href='people_seek1.asp?pageno=<%=pno%>&amp;txt_name=<%=seek_name%>&amp;sel_xueli=<%=seek_xueli%>&amp;sel_zhicheng=<%=seek_zhicheng%>&amp;sel_zhuangkuang=<%=seek_zhuangkuang%>'><%=pno%></a></b>
另外<%=%>这个格式不能错,少一个=或%都不行
你asp基础知识没搞清楚,建议你多看看书上的例子
 
csz说得正确的,
另:我的目的是想要实现分页,每页8行,但是现在实现不了分页了,
已有九条数据, 全部显示在一页, 而且页面最下面显示不出页号,
这是为什么?
我把它全贴出来了。
<!--#include file="conn.asp"-->
<% pageno=request.querystring("pageno") %>
<!--获得查询者输入信息-->
<% seek_name=Trim(Request("txt_name"))
seek_xueli=Trim(Request("sel_xueli"))
seek_zhicheng=Trim(Request("sel_zhicheng"))
seek_zhuangkuang=Trim(Request ("sel_zhuangkuang")) %>
<!--如果查询者什么都没有输入-->
<% if((seek_name="") and (seek_xueli="选择") and (seek_zhicheng="选择") and (seek_zhuangkuang="选择")) then
%>
<% Response.Write "您没有输入查询条件!" %>
<% Response.End%>
<% end if %>
<html>
<head>
<title>Untitleddo
cument</title>
<meta http-equiv="Content-Type" content="text/html;
charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="467" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="162" height="68" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="162" height="68">
<p align="center"><a href="index_people.htm">回到查询</a></p>
</td>
</tr>
</table>
</td>
<td width="163" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="163" height="68">
<div align="center"><font color="#FF3333">查询结果</font></div>
</td>
</tr>
</table>
</td>
<td width="142" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="142" height="68">
<div align="center"><a href="insert.asp">增加</a></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p>
<%
sql_text="select * from lyb where "
'<!--查看是否输入了人名-->
if seek_name="" then

'<!--如果没有输入人名-->
sql_text=sql_text
else

'<!--如果输入了人名-->
sql_name="name ='" &amp;
seek_name &amp;
"'"
sql_text = sql_text &amp;
sql_name
end if
'<!--查看是否选择了学历-->
if seek_xueli="选择" then

'<!--如果没有选择学历-->
sql_text=sql_text
else

if (seek_name<>"") then

'<!--在前面输入了要查询的人名-->
sql_xueli= "and xl= '"&amp;
seek_xueli&amp;"'"
else

sql_xueli=" xl ='" &amp;
seek_xueli&amp;"'"
end if
sql_text=sql_text &amp;
sql_xueli
end if
'<!--查看是否选择了职称-->
if seek_zhicheng="选择" then

'<!--如果没有选择职称-->
sql_text=sql_text
else

if ((seek_name<>"") or (seek_xueli<>"选择")) then

'<!--在前面输入了人名或选择了学历-->
sql_zhicheng=" and zc ='" &amp;seek_zhicheng&amp;
"'"
else

sql_zhicheng=" zc ='" &amp;
seek_zhicheng&amp;"'"
end if
sql_text=sql_text &amp;
sql_zhicheng
end if
'<!--查看是否选择了现在状况-->
if seek_zhuangkuang="选择" then

'<!--如果没有选择现在状况-->
sql_text=sql_text
else

if ((seek_name<>"") or (seek_xueli<>"选择") or (seek_zhicheng<>"选择")) then

'<!--在前面输入了人名或选择了学历或选择了职称-->
sql_zhuangkuang=" and zk ='" &amp;seek_zhuangkuang&amp;
"'"
else

sql_zhuangkuang= " zk = '" &amp;
seek_zhuangkuang&amp;
"'"
end if
sql_text=sql_text &amp;
sql_zhuangkuang
end if %>
<% Set rs=Server.CreateObject("ADODB.Recordset")
rs.open sql_text,conn,1,1
if isempty(pageno) or cint(pageno)<1 or cint(pageno)>mpage then
pageno=1
end if
rs.absolutepage=pageno
%>
<%
rs.pagesize=8
mpage=rs.pagecount
rc=rs.pagesize
re=1
do while not rs.eof
name=rs("name")
xl=rs("xl")
zc=rs("zc")
zk=rs("zk")
%>
</p>
<table width="467" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="69" valign="top" width="117" bgcolor="#e1e1e1">
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="117" height="67">
<div align="center"><font color="#000000">姓名:</font></div>
</td>
</tr>
</table>
</td>
<td valign="top" width="116">
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="116" height="67">
<div align="center"> <%=name%> </div>
</td>
</tr>
</table>
</td>
<td width="118" valign="top" bgcolor="#e1e1e1">
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000033" bgcolor="#CC0000">
<tr>
<td width="119" height="67">
<div align="center">学历:</div>
</td>
</tr>
</table>
</td>
<td width="1"></td>
<td width="115" valign="top">
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="256" height="67">
<div align="center"> <%=xl%> </div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="69" valign="top" bgcolor="#e1e1e1">
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="117" height="69">
<div align="center"><font color="#000000">职称:</font></div>
</td>
</tr>
</table>
</td>
<td valign="top">
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="116" height="69">
<div align="center"> <%=zc%> </div>
</td>
</tr>
</table>
</td>
<td valign="top" bgcolor="#e1e1e1" colspan="2">
<table width="99%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="118" height="69">
<div align="center">状况:</div>
</td>
</tr>
</table>
</td>
<td valign="top">
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="256" height="67">
<div align="center"> <%=zk%> </div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="0"></td>
<td></td>
<td bgcolor="#e1e1e1"></td>
<td bgcolor="#e1e1e1"></td>
<td></td>
</tr>
</table>
<table width="468" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="468" height="49" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="468" height="49" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="468" height="58" valign="top">
<div align="center">
<p>&amp;nbsp;</p>
<p align="left">
<%
rs.movenext
loop%>
</p>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="694" border="0" cellspacing="0" cellpadding="2" align="center" height="25" bgcolor="F2F2F2">
<tr>
<td width="226"></td>
<td align="center" width="240"> </td>
<td width="330" align="right">[
<% for pno=1 to mpage
if pno=cint(pageno) then
%>
<%=pno%>
</font><%else
%>
<b><a href='people_seek1.asp?pageno=<%=pno%>&amp;txt_name=<%=seek_name%>&amp;sel_xueli=<%=seek_xueli%>&amp;sel_zhicheng=<%=seek_zhicheng%>&amp;sel_zhuangkuang=<%=seek_zhuangkuang%>'><%=pno%></a></b>
<%end if%>
<%next%>
]</td>
</tr>
</table>
<p>&amp;nbsp;</p>
</body>
</html>

 
唉 看了你的程序 感觉乱 不是我打击你 唉 基础不行
遇到问题要多分析 多思考 仔细分析每一个步骤
好好想想分页应该是怎么实现的
先指定页的大小 再指定数据页编号,而不是先指定数据页编号 再指定数据页的大小
 
我是刚刚学了十天,
想自已做个动态查询分页显示结果的东西。
在上面的程序中关于显示分页的语句不是很多,
你帮我改一下好吗?
 
关于分页 先指定页的大小 再指定数据页编号
还有参数的获取 用QueryString 与 Form都可以 你自己好好想想
主要靠自己多思考呀

 
多人接受答案了。
 
顶部