一个经典的问题(asp)
我想在我的页面中使用分页查询
但是我不知道为什么在不分页的时候没有什么问题,但是一分的情况下,第二个页面就出错了
我看了论坛上的一些方法
但是还是不行.高手们,给点意见啊
问题点数:20、回复次数:14Top
1 楼jinjie0577(风之友)回复于 2005-04-01 16:52:42 得分 0
到底是怎么个出错法,你这样说,叫别人怎么理解啊Top
2 楼venket(创业先锋)回复于 2005-04-01 16:56:08 得分 0
是第二个页面把所有的数据都显示出来了
就是说,我们之前的传来的条件没有效了Top
3 楼venket(创业先锋)回复于 2005-04-01 16:58:49 得分 0
代码如下:各位帮帮忙啊
就是第二个页面开始,出来的数据,不是我想要查询的数据了
<!--#include file="../CONN.INC"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../main/style.css" type="text/css">
<style type="text/css">
<!--
@media print{
INPUT {suppComplay:none}
}
th {
font-size: 14px;
color: #6f6f6f;
padding: 5px;
}
td {
padding: 5px;
}
.style1 {
font-size: 14px;
color: #333333;
}
.style2 {font-size: 12px}
.style3 {color: #008BCE}
.style4 {font-size: 14px}
-->
</style>
</head>
<body bgcolor="#FFFFFF" topmargin="8">
<p><div align="left">
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><span class="style1"><br>
目前操作栏目 :供应商信息</span></td>
<td> </td>
</tr>
<tr>
<td><blockquote>
<p><span class="style2">[</span> <a href=suppCompNew.asp><span class="style1">添加新的供应商信息</span></a> <span class="style2">]</span></p>
</blockquote></td>
<td><div align="right">
<form name="form1" method="post" action="suppComp.asp">
<select name="flt" id="flt">
<option value="">全部</option>
<option value="where comp_name like">供应商</option>
<option value="where tel like">电话</option>
</select>
<input type="text" name="sqlFlt">
<input type="submit" name="Submit" value="提交">
</form>
</div></td>
</tr>
</table>
<p><blockquote>
<table width="80%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#999999" id="mxh">
<tr align="center" bgcolor="#008BCE">
<td colspan="9"><span class="style4"><font color="#FFFFFF">供 应 商 管 理 页 面</font></span></td>
</tr>
<tr bgcolor="#f5f5f5" align="center">
<th scope="col"><span class="style3">供应商</span></th>
<th scope="col"><span class="style3">地址</span></th>
<th scope="col"><span class="style3">电话</span></th>
<th scope="col"><span class="style3">传真号码</span></th>
<th scope="col"><span class="style3">联系人</span></th>
<th colspan="2" scope="col"><span class="style3">功能</span></th>
</tr>
<%
const MaxPerPage=6
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
dim idlist
dim name
dim sql
dim rs
i=0
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
%>
<%
if(len(trim(request("flt")))>0) Then
sql="select * from ms_company "&request("flt")&"'%"&request("sqlFlt")&"%'"
else
sql="select * from ms_company"
end if
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,"suppComp.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"suppComp.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"suppComp1.asp"
end if
end if
rs.close
end if
set rs=nothing
conn.close
set conn=nothing
sub showContent
%>
<%do while not rs.eof%>
<tr bgcolor="#FFFFFF">
<td><div align="center"><%=trim(rs("comp_name"))%></div></td>
<td><div align="center" style="word-Wrap:break-word"><%=trim(rs("comp_addr"))%></div></td>
<td height="20" align="center"><%=rs("tel")%></td>
<td><div align="center"><%=rs("fax")%></div></td>
<td><div align="center"><%=rs("person")%></div></td>
<td align="center"><a href="suppCompUpd.asp?compCode=<%=rs("comp_code")%>"><img src="../images/edit.gif" width="16" height="16" border="0"></a></td>
<td align="center"><img src="../images/delete.gif" width="16" height="16" border="0" onclick="f_del('<%=trim(rs("comp_code"))%>')"></a></td>
</tr>
<%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
</table>
<br>
<table width="80%" height="26" border="0" align="center" cellpadding="0" cellspacing="0">
<tr class="font">
<td align="right"><span class="style1">
<%
end sub
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='right'> "
if CurrentPage<2 then
response.write "<font color='#000080'>首页 上一页</font> "
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 "<font color='#000080'>下一页 尾页</font>"
else
response.write "<a href="&filename&"?page="&(CurrentPage+1)&">"
response.write "下一页</a> <a href="&filename&"?page="&n&">尾页</a>"
end if
response.write " 页次:<strong><font color=red>"&CurrentPage&"</font>/"&n&"</strong>页 "
response.write " 共<b><font color=red>"&totalnumber&"</font></b>条 <b>"&maxperpage&"</b>条/页</font> "
end function
%>
<%
set rs=nothing
%>
</span>
</td>
</tr>
</table>
</div>
</body>
</html>
<script language="javascript">
function f_del(i)
{
if(confirm("你想要删除吗?"))
{
window.location="suppCompDel.asp?compCode="+i;
}
}
</script>
Top
4 楼jinjie0577(风之友)回复于 2005-04-01 17:04:48 得分 20
问题就是出在你点上一页或下一页时,丢失了搜索的关键字,应该把关键字继续传递下去才会有效
如:
response.write "<a href="&filename&"?page=1&keyword="&request("keyword")&">首页</a> "
response.write "<a href="&filename&"?page="&CurrentPage-1&"&keyword="&request("keyword")&">>上一页</a> "
其中keyword为关键字的变量名称Top
5 楼lstup(流水)回复于 2005-04-01 17:12:31 得分 0
http://www.37zz.com/ShowPost.asp?id=58
看看,会有收获的Top
6 楼poonzsp(怒放的生命)回复于 2005-04-01 17:14:50 得分 0
没有传输参数`Top
7 楼zhanglemail(咕噜)回复于 2005-04-01 17:30:08 得分 0
楼上的都回答了!!!Top
8 楼yifan268(天涯)回复于 2005-04-01 17:33:05 得分 0
当你按下一页的时候,你的一个变量当中的值没有了.
所以你要用一个隐含字断继续传递...Top
9 楼QSmile(RedFox)回复于 2005-04-02 11:52:02 得分 0
把 文件定义成两种参数方式
一种是用 Form 一种是用QueryString 两种同时工作
QueryString 时如这样 sss.asp?keyword=张三&GroupID=1&page=5Top
10 楼hnzhangyls(守望的狮子)回复于 2005-04-02 11:57:18 得分 0
变量的值传丢啦Top
11 楼daknis(杰瑞)回复于 2005-04-02 13:31:30 得分 0
仔细检查一下Top
12 楼Aspclass(Asp初学者)回复于 2005-04-02 14:04:18 得分 0
你娃娃 哦。。你的filename是什么意思。。。该是一个文件名吧。。
如果是你前面又没有定义 你的filename=什么呢??
建议你不要这样写可以这样。。
做面码都是在本面里面做。如 本页为 1.asp
response.write "<a href="1.asp?page="&CurrentPage-1&"">上一页</a> "
这样写就应该对了
Top
13 楼LW1981(旋转的线)回复于 2005-04-02 16:55:25 得分 0
用session把關鍵字一直傳下去Top
14 楼riyao(日尧)回复于 2005-04-02 16:58:27 得分 0
参数没传递。。Top




