| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 430 人关注过本帖
标题:[求助]【新人】分页显示出错问题
只看楼主 加入收藏
xinzheng
Rank: 1
等 级:新手上路
帖 子:193
专家分:0
注 册:2007-7-22
收藏
 问题点数:0 回复次数:5 
[求助]【新人】分页显示出错问题

我有一个产品页面:produce.asp
1.单独打开显示所有产品
2.从left.asp点产品分类链接,显示所点击分类的所有产品
3.从top.asp点查询产品,显示所有产品名字包含:keyword的所有产品
现在上面三个功能都能实现,就是在3的分页链接出错,第一页显示正确,点下页,就显示了1的第二页,但是当操作2时点下页显示的是正确的该分类的第二页,不知道问题出在那里,代码有点多,真是有点不好意思,可我就是找不到原因,希望大家能抽空帮我看看,万分感激!!!

注:其中三的代码还是:愿望,朋友帮助写的

---------produce.asp 里与分页有关的语句
<%
if not isempty(request("pageno")) or request("pageno")<>0 then
pageno=request.querystring("pageno")
else
pageno=1
end if
if request("pro_type") <> "" then
pro_type=request("pro_type")
else
pro_type=0
end if
if request("pro_type2") <> "" then
pro_type2=request("pro_type2")
else
pro_type2=0
end if
if request("keyword")<>"" then
pro_name=request("keyword")
else
pro_name="无"
end if
%>



<%
strsql="select * from pro_list order by id desc"
if pro_type<>0 then
strsql="select * from pro_list where pro_type="&pro_type&" order by id desc"
end if
if pro_type2<>0 then
strsql="select * from pro_list where pro_type2="&pro_type2&" order by id desc"
end if
if pro_name<>"无" then
strsql="select * from pro_list where pro_name like '%"&pro_name&"%' order by id desc"
end if
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 1, 1
%>
<%if rs.eof then%>
<table width="493" border="0" cellspacing="0" cellpadding="5" align="center">
<tr>
<td width="483" align=center class="zhengwen">无相关商品</td>
</tr>
</table>
<% else
rs.PageSize =6 '每页记录条数
iCount=rs.RecordCount '记录总数
iPageSize=rs.PageSize
maxpage=rs.PageCount
page=request("page")

if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if

if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if

rs.AbsolutePage=Page

if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if

For i=1 To x
%>




<%rs.movenext
next
call PageControl(iCount,maxpage,page,"border=0 align=center","<p align=center class='zhengwen'>")
end if
rs.close
set rs=nothing
Sub PageControl(iCount,pagecount,page,table_style,font_style)
'生成上一页下一页链接
Dim query, a, x, temp
action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")

query = Split(Request.ServerVariables("QUERY_STRING"), "&")
For Each x In query
a = Split(x, "=")
If StrComp(a(0), "page", vbTextCompare) <> 0 Then
temp = temp & a(0) & "=" & a(1) & "&"
End If
Next

Response.Write("<table " & Table_style & ">" & vbCrLf )
Response.Write("<form method=get onsubmit=""document.location = '" & action & "?" & temp & "Page='+ this.page.value;return false;""><TR>" & vbCrLf )
Response.Write("<TD align=right>" & vbCrLf )
Response.Write(font_style & vbCrLf )

if page<=1 then
Response.Write ("首页 " & vbCrLf)
Response.Write ("上页 " & vbCrLf)
else
Response.Write("<A HREF=" & action & "?" & temp & "Page=1>首页</A> " & vbCrLf)
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page-1) & ">上页</A> " & vbCrLf)
end if

if page>=pagecount then
Response.Write ("下页 " & vbCrLf)
Response.Write ("尾页 " & vbCrLf)
else
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page+1) & ">下页</A> " & vbCrLf)
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & pagecount & ">尾页</A> " & vbCrLf)
end if

Response.Write(" 页次:" & page & "/" & pageCount & "页" & vbCrLf)
Response.Write(" 共有" & iCount & "种商品" & vbCrLf)
Response.Write(" 转到" & "<INPUT TYEP=TEXT NAME=page SIZE=1 Maxlength=5 VALUE=" & page & ">" & "页" & vbCrLf & "<INPUT type=submit style=""font-size: 9pt"" value=GO class=b2>")
Response.Write("</TD>" & vbCrLf )
Response.Write("</TR></form>" & vbCrLf )
Response.Write("</table>" & vbCrLf )
End Sub
%>
=========================================================================
其中pro_type和pro_type2是从left.asp里传过来的具体语句:
<%
strsql="select * from pro_type"
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 1, 1
totalRecs = rs.RecordCount
%>
<%
strsql="select * from pro_type2"
set js = Server.CreateObject("ADODB.Recordset")
js.Open strsql, conn, 1, 1
totalRecs = rs.RecordCount
%>



<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<% while not rs.eof %>
<tr>
<td height="26" class="b-1-gray"> <img src="images/doc.jpg" width="10" height="10"> <span class="title05"><a href="product.asp?pro_type=<%=rs("pro_type")%>"><font color="#333333"><%= rs("type_name") %></font></a></span>
</td>
</tr>
<% rs.movenext
wend
rs.close
set rs=nothing
%>
</table>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<% while not js.eof %>
<tr>
<td height="26" class="b-1-gray"> <img src="images/doc.jpg" width="10" height="10"> <span class="title05"><a href="product.asp?pro_type2=<%=js("pro_type2")%>"><font color="#333333"><%= js("type_name2") %></font></a></span>
</td>
</tr>
<% js.movenext
wend
js.close
set js=nothing
%>
</table>
===========================================================================
其中keyword是从top.asp中传来的,具体语句
<script>
getit = function (id) {
return(document.getElementById(id));
}

process = function () {
var f = getit('form1');
f.action = getit('otype').value;
f.submit();
}
</script>
<form id="form1" method="post" >
<tr>
<td width="64%" style="padding-left:6px"><input name="keyword" type="text" size="8" />
</td>
<td width="50%" style="padding-left:6px"><select name="select" id="otype">
<option value="product.asp">经营药妆</option>
<option value="news.asp">企业新闻</option>
<option value="zhishi.asp">药妆知识</option>
</select>
</td>
<td width="64%" style="padding-left:6px"><input type="image" border="0" name="submit" src="images/search1.gif" width="56" height="19" onclick="process();" />
</td>
</tr>
<tr> </tr>
</form>

搜索更多相关主题的帖子: 新人 
2007-08-06 18:44
madpbpl
Rank: 4
等 级:贵宾
威 望:11
帖 子:2876
专家分:244
注 册:2007-4-5
收藏
得分:0 
<%
dim SearchStr
SearchStr=""
strsql="select * from pro_list order by id desc"
if pro_type<>0 then
strsql="select * from pro_list where pro_type="&pro_type&" order by id desc"
SearchStr = SearchStr &"&pro_type="&pro_type
end if
if pro_type2<>0 then
strsql="select * from pro_list where pro_type2="&pro_type2&" order by id desc"
SearchStr = SearchStr &"&pro_type2="&pro_type2
end if
if pro_name<>"无" then
strsql="select * from pro_list where pro_name like '%"&pro_name&"%' order by id desc"
SearchStr = SearchStr &"&pro_name="&pro_name
end if
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 1, 1
%>
在分页里把
<%=SearchStr%>
加进去
2007-08-06 19:11
xinzheng
Rank: 1
等 级:新手上路
帖 子:193
专家分:0
注 册:2007-7-22
收藏
得分:0 
你能把分页完整改下吗?老是说我的水平还没到能象你说的那么改的地步,谢谢,帮把分页代码完整改下好吗?
2007-08-06 19:20
madpbpl
Rank: 4
等 级:贵宾
威 望:11
帖 子:2876
专家分:244
注 册:2007-4-5
收藏
得分:0 
<A HREF=" & action & "?" & temp & "Page=1"& SearchStr &">首页</A>
试试这样行不行,其他依次类推
2007-08-06 21:22
xinzheng
Rank: 1
等 级:新手上路
帖 子:193
专家分:0
注 册:2007-7-22
收藏
得分:0 
问题已经解决,再次感谢:愿望
2007-08-06 21:52
wucifei
Rank: 1
等 级:新手上路
帖 子:42
专家分:0
注 册:2007-8-3
收藏
得分:0 
怎么解决是,共享一下!!
2007-08-06 22:30
快速回复:[求助]【新人】分页显示出错问题
数据加载中...
 
   



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

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