SQL---union在asp分页中的问题,莫名其妙~~~~~~~~~~~ ( 积分: 200 )

  • 主题发起人 主题发起人 corser
  • 开始时间 开始时间
C

corser

Unregistered / Unconfirmed
GUEST, unregistred user!
比如数据库中每个表由10条记录,每页我设置显示5条。问题是现在第一页好好的。第二页竟然是空的了。应该有剩下5条才对啊。为了保持代码完整性,我全部粘贴上来了。大家可以模拟建一个数据库。把代码贴到自己机子上运行看看。用select * form 某个表就好好的,一点问题没有。可是我要搜索的是六个表(每个表结构完全一样,就是数据不同。)中p_type="aa"的记录。就是多表查询,如果是单表,那么分页正常。
多表查询到第二页就没记录了。到底是什么回事?或者大家有更好的多表+asp分页查询显示也可以写上来告诉我。
谢谢大家了,那么热的天。
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;
&quot;http://www.w3.org/TR/html4/loose.dtd&quot;>
<html>
<head>
<%
Set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
strcon=&quot;provider=microsoft.jet.oledb.4.0;data source=&quot;&amp;
_
server.mappath(&quot;database/product.mdb&quot;)
conn.Open strcon
Set rs = Server.CreateObject (&quot;ADODB.Recordset&quot;)

SQL=&quot;select * from 陈设藏品 where p_type='&quot;&amp;request.Form(&quot;select&quot;)&amp;&quot;' union all select * from 挂件生肖 where p_type='&quot;&amp;request.Form(&quot;select&quot;)&amp;&quot;' union all select * from 汽车内饰 where p_type='&quot;&amp;request.Form(&quot;select&quot;)&amp;&quot;' union all select * from 生活保健 where p_type='&quot;&amp;request.Form(&quot;select&quot;)&amp;&quot;' union all select * from 首饰手镯 where p_type='&quot;&amp;request.Form(&quot;select&quot;)&amp;&quot;' union all select * from 文房四宝 where p_type='&quot;&amp;request.Form(&quot;select&quot;)&amp;&quot;'&quot;
rs.Open sql, conn, 1
rs.PageSize = 5 '每页显示记录数
if Not IsEmpty(Request(&quot;Page&quot;)) then
'如果PAGE已经初始化...
Page = CInt(Request(&quot;Page&quot;)) '接收PAGE并化为数字型赋给PAGE变量
if Page > rs.PageCount then
'如果接收的页数大于总页数
page=Rs.pageCount
rs.AbsolutePage = rs.PageCount '设置当前显示页等于最后页
else
rs.AbsolutePage = Page '显示当前页等于接收的页数
end if
else

Page = 1 '如果page未被初始化则设为1
End if
rs.AbsolutePage=page
%>
<meta http-equiv=&quot;Content-Type&quot;
content=&quot;text/html;
charset=gb2312&quot;>
<title>青岛玉网主页</title>
<style type=&quot;text/css&quot;>
<!--
.style17 { font-size: 12px;
font-weight: bold;
color: #51588c;
font-family: &quot;宋体&quot;;
}
.style22 { font-family: &quot;宋体&quot;;
font-size: 12px;
color: #6666FF;
}
.style5 { font-family: tahoma;
font-size: 11px;
color: #ff7800;
}
.style7 {color: #767676}
.input { BORDER-RIGHT: #000000 1px solid;
PADDING-RIGHT: 2px;
BORDER-TOP: #000000 1px solid;
PADDING-LEFT: 2px;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
PADDING-BOTTOM: 2px;
BORDER-LEFT: #000000 1px solid;
COLOR: #000000;
PADDING-TOP: 2px;
BORDER-BOTTOM: #000000 1px solid
}
.style36 {color: #FFFFFF;
font-family: &quot;宋体&quot;;
font-size: 12px;
}
.style37 {color: #FF3366}
.style46 {font-family: &quot;宋体&quot;;
font-size: 14px;
color: #6666FF;
}
.style48 {color: #FF3366;
font-size: 12px;
}
.style49 {color: #0033CC}
-->
</style>
<link href=&quot;CSS/text%20link.css&quot;
rel=&quot;stylesheet&quot;
type=&quot;text/css&quot;>
<style type=&quot;text/css&quot;>
<!--
.style50 {color: #FFFFFF}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
color: #cc66cc;
}
a:active {
text-decoration: none;
}
-->
</style>
</head>
<body>
<!-- ImageReady Slices (main.psd) -->
<TABLE WIDTH=780 height=&quot;164%&quot;
BORDER=0 align=&quot;center&quot;
CELLPADDING=0 CELLSPACING=0>
<TR align=&quot;left&quot;
valign=&quot;top&quot;>
<TD COLSPAN=2><table width=&quot;780&quot;
border=&quot;0&quot;
cellspacing=&quot;0&quot;
cellpadding=&quot;0&quot;>
<tr bgcolor=&quot;#CACDDF&quot;>
<td height=&quot;4&quot;
align=&quot;left&quot;
valign=&quot;top&quot;><img src=&quot;file:///C|/Documents%20and%20Settings/sj/&amp;#26700;&amp;#38754;/&amp;#27169;&amp;#26495;/&amp;#27431;&amp;#32654;&amp;#21830;&amp;#21153;&amp;#39764;&amp;#26495;/web_057/Html/images/spacer.gif&quot;
width=&quot;1&quot;
height=&quot;4&quot;></td>
</tr>
<tr>
<td align=&quot;left&quot;
valign=&quot;top&quot;><table width=&quot;779&quot;
height=&quot;39&quot;
border=&quot;0&quot;>
<tr>
<td width=&quot;189&quot;
height=&quot;35&quot;
valign=&quot;middle&quot;><div align=&quot;left&quot;><span class=&quot;style37&quot;>客服热线:0532-88888888</span></div></td>
<td width=&quot;0&quot;
height=&quot;35&quot;><table width=&quot;583&quot;
border=&quot;0&quot;>
<tr>
<td width=&quot;30&quot;><img src=&quot;images/happyking_05.jpg&quot;
width=&quot;27&quot;
height=&quot;27&quot;></td>
<td width=&quot;70&quot;
valign=&quot;middle&quot;><SPAN style=&quot;FONT-SIZE: 9pt&quot;><A
href=&quot;http://www.ehaier.com/jsp/cart/CartList.jsp&quot;><FONT
color=#ff0066>我的购物车</FONT></A></SPAN></td>
<td width=&quot;30&quot;><img src=&quot;images/happyking_09.jpg&quot;
width=&quot;27&quot;
height=&quot;27&quot;
align=&quot;top&quot;></td>
<td width=&quot;56&quot;
valign=&quot;middle&quot;><FONT color=#ff0066><SPAN
style=&quot;FONT-SIZE: 9pt&quot;><A
href=&quot;http://www.ehaier.com/sysstatic/flow_demo.jsp&quot;><FONT
color=#ff0066>购物指南</FONT></A></SPAN></FONT></td>
<td width=&quot;31&quot;><img src=&quot;images/happyking_11.jpg&quot;
width=&quot;27&quot;
height=&quot;27&quot;
align=&quot;top&quot;></td>
<td width=&quot;42&quot;
valign=&quot;middle&quot;><A
href=&quot;guestbook/index.asp&quot;><FONT
color=#ff0066><SPAN
style=&quot;FONT-SIZE: 9pt&quot;>留言板</SPAN></FONT></A></td>
<td width=&quot;287&quot;><form name=&quot;form1&quot;
method=&quot;post&quot;
action=&quot;&quot;>
<table width=&quot;294&quot;
border=&quot;0&quot;>
<tr>
<td width=&quot;44&quot;><div align=&quot;right&quot;><img src=&quot;images/search1.gif&quot;
width=&quot;20&quot;
height=&quot;16&quot;></div></td>
<td width=&quot;62&quot;
valign=&quot;middle&quot;><span class=&quot;style22&quot;>商品搜索</span></td>
<td width=&quot;102&quot;><select name=&quot;select&quot;>
<option>玉镯</option>
<option>项链</option>
<option>生肖</option>
<option>手球</option>
<option>玉印</option>
<option>玉枕</option>
<option>玉席玉垫</option>
<option>摆设</option>
</select></td>
<td width=&quot;57&quot;><img src=&quot;images/go1.gif&quot;
width=&quot;19&quot;
height=&quot;19&quot;
border=&quot;0&quot;>
</td>
</tr>
</table>
</form></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td width=&quot;0&quot;
align=&quot;left&quot;
valign=&quot;top&quot;><table width=&quot;100%&quot;
height=&quot;94&quot;
border=&quot;0&quot;>
<tr>
<td><span class=&quot;style37&quot;><img src=&quot;images/logo%20copy.gif&quot;
width=&quot;140&quot;
height=&quot;60&quot;></span></td>
<td><img src=&quot;images/gridflux800.jpg&quot;
width=&quot;633&quot;
height=&quot;88&quot;></td>
</tr>
</table></td>
</tr>
<tr>
<td height=&quot;0&quot;
align=&quot;left&quot;
valign=&quot;top&quot;><div align=&quot;center&quot;>
<table width=&quot;777&quot;
border=&quot;0&quot;
cellspacing=&quot;0&quot;
cellpadding=&quot;0&quot;>
<tr>
<td width=&quot;777&quot;
height=&quot;26&quot;
align=&quot;left&quot;
valign=&quot;top&quot;
bgcolor=&quot;#FFFFFF&quot;><table width=&quot;776&quot;
height=&quot;28&quot;
border=&quot;0&quot;>
<tr background=&quot;images/menu.jpg&quot;>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style37 style36&quot;><a href=&quot;index.asp&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>首页</a></div></td>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;search.asp&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>首饰/手镯</a></div></td>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;guashi.asp&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>挂件/生肖</a></div></td>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;life.asp&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>生活/保健</a></div></td>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;wenfang.asp&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>文房四宝</a></div></td>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;car.asp&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>汽车内饰</a></div></td>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;layout.asp&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>陈设藏品</a></div></td>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;html/maintain.htm&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>玉的保养</a></div></td>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;html/culture.htm&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>玉的文化</a></div></td>
<td width=&quot;77&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;html/introduce.htm&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>玉网简介</a></div></td>
</tr>
</table></td>
</tr>
</table>
<table width=&quot;778&quot;
border=&quot;0&quot;>
<tr>
<td width=&quot;487&quot;><div align=&quot;left&quot;>
<table width=&quot;588&quot;
height=&quot;21&quot;
border=&quot;0&quot;>
<tr>
<td width=&quot;352&quot;
class=&quot;style17&quot;>您的位置:首页</td>
<td width=&quot;778&quot;
class=&quot;style37&quot;>祝您在青岛玉网购物愉快!</td>
</tr>
</table>
</div></td>
</tr>
</table>
</div></td>
</tr>
</table>
</TD>
</TR>
<TR>
<TD width=&quot;0&quot;
align=&quot;left&quot;
valign=&quot;top&quot;><div style=&quot;padding-left:0px;
padding-bottom:5px&quot;>
<table width=&quot;98%&quot;
height=&quot;30%&quot;
border=&quot;0&quot;>
<tr>
<td width=&quot;233&quot;
height=&quot;30&quot;
align=&quot;center&quot;
valign=&quot;middle&quot;
background=&quot;images/kettle_2.gif&quot;><div align=&quot;center&quot;
class=&quot;style46&quot;>会员登录</div></td>
</tr>
</table>
<table width=&quot;230&quot;
border=&quot;0&quot;
bordercolor=&quot;#CCCCCC&quot;>
<tr>
<td width=&quot;238&quot;
height=&quot;29&quot;><TABLE width=&quot;100%&quot;
align=left cellPadding=4 cellSpacing=1 bordercolor=&quot;#990033&quot;
bgColor=#ffffff>
<TBODY>
<TR>
<TD align=middle colSpan=2 height=5></TD>
</TR>
<FORM action=admin.php method=post>
<TR>
<TD style=&quot;FONT-SIZE: 12px;
COLOR: #000000&quot;
align=middle
width=&quot;43%&quot;
height=22><div align=&quot;center&quot;>会员名:</div></TD>
<TD width=&quot;57%&quot;
height=22><div align=&quot;center&quot;>
<INPUT class=input
maxLength=20 size=11 name=muser>
</div></TD>
</TR>
<TR>
<TD style=&quot;FONT-SIZE: 12px;
COLOR: #000000&quot;
align=middle
width=&quot;43%&quot;
height=22><div align=&quot;center&quot;>密 码:</div></TD>
<TD width=&quot;57%&quot;
height=22><div align=&quot;center&quot;>
<INPUT class=input
type=password maxLength=20 size=11 name=mpass>
</div></TD>
</TR>
<TR>
<TD align=right height=20><a href=&quot;user_registration.asp&quot;><img src=&quot;images/zc.jpg&quot;
width=&quot;74&quot;
height=&quot;32&quot;
border=&quot;0&quot;
align=&quot;baseline&quot;></a> </TD>
<TD vAlign=top height=20><div align=&quot;center&quot;><img src=&quot;images/dl2.jpg&quot;
width=&quot;74&quot;
height=&quot;31&quot;></div></TD>
</FORM>
</TABLE></td>
</tr>
<tr>
<td height=&quot;355&quot;
valign=&quot;top&quot;><div align=&quot;left&quot;>
<table width=&quot;100%&quot;
height=&quot;234&quot;
border=&quot;0&quot;
bordercolor=&quot;#FFFFFF&quot;>
<tr>
<td width=&quot;237&quot;
height=&quot;30&quot;
background=&quot;images/kettle_1.gif&quot;><div align=&quot;center&quot;
class=&quot;style49&quot;>新品推荐</div></td>
</tr>
<tr>
<td height=&quot;198&quot;
valign=&quot;top&quot;>&amp;nbsp;</td>
</tr>
</table>
<table width=&quot;238&quot;
border=&quot;0&quot;>
<tr>
<td width=&quot;208&quot;
height=&quot;33&quot;
background=&quot;images/kettle_4.gif&quot;><div align=&quot;center&quot;
class=&quot;style46&quot;>
<p>客服中心</p>
</div></td>
</tr>
<tr>
<td height=&quot;133&quot;
valign=&quot;top&quot;
bordercolor=&quot;#CCCCCC&quot;><div align=&quot;center&quot;>
<p align=&quot;left&quot;
class=&quot;style48&quot;>您的任何疑问,我们将全力以赴为您解决!</p>
<p align=&quot;left&quot;
class=&quot;style48&quot;><span class=&quot;style49&quot;>客服热线</span><img src=&quot;images/1111485546.gif&quot;
width=&quot;20&quot;
height=&quot;20&quot;>:<span class=&quot;style49&quot;>0532-88888888 13888888888 </span></p>
<p align=&quot;left&quot;
class=&quot;style48&quot;><span class=&quot;style49&quot;>在线客服</span><img src=&quot;images/1106908031.gif&quot;
width=&quot;20&quot;
height=&quot;20&quot;>:<span class=&quot;style49&quot;>111111111</span></p>
<p align=&quot;left&quot;
class=&quot;style48&quot;><span class=&quot;style49&quot;>客服</span><img src=&quot;images/1111485629.gif&quot;
width=&quot;16&quot;
height=&quot;16&quot;>:<span class=&quot;style49&quot;>xxxx@xxx.com</span></p>
</div></td>
</tr>
</table>
</div></td>
</tr>
</table>
</div></TD>
<TD width=&quot;539&quot;
align=&quot;left&quot;
valign=&quot;top&quot;><table width=&quot;539&quot;
border=&quot;0&quot;
cellspacing=&quot;0&quot;
cellpadding=&quot;0&quot;>
<tr>
<td height=&quot;460&quot;
align=&quot;left&quot;
valign=&quot;top&quot;><div style=&quot;padding-left:14px;
padding-top:15px&quot;>
<div align=&quot;center&quot;><font size=&quot;2&quot;> <strong>
<%
i=0
response.Write(rs.recordcount)
do while not rs.eof
%>
</strong></font> </div>
<table width=&quot;600&quot;
border=&quot;0&quot;
ALIGN=&quot;CENTER&quot;>
<tr>
<td WIDTH=106><img src=&quot;<%=rs(&quot;pic_addr&quot;)%>&quot;
alt=&quot;&quot;
width=&quot;106&quot;
height=&quot;100&quot;></td>
<td WIDTH=98 valign=&quot;top&quot;
background=&quot;images/back_rep_2.gif&quot;><p><%=rs(&quot;product_name&quot;)%></p>
<p><span class=&quot;style5&quot;>市场价:<span class=&quot;style7&quot;>¥</span></span><%=rs(&quot;price&quot;)%></p>
<p><span class=&quot;style5&quot;>会员价:<span class=&quot;style7&quot;>¥</span></span><%=rs(&quot;vip_price&quot;)%></p></td>
<td WIDTH=382 valign=&quot;top&quot;
background=&quot;images/back_rep_2.gif&quot;><span class=&quot;style5&quot;><br>
<%=rs(&quot;introduction&quot;)%> </span></td>
</tr>
<tr background=&quot;images/back_rep_2.gif&quot;>
<td COLSPAN=&quot;4&quot;
align=&quot;center&quot;>&amp;nbsp;</td>
</tr>
</table>
<%
'当显示记录大于maxperpage时结束这页
i=i+1
IF i>=rs.PageSize then
exitdo

rs.movenext
loop
%>
<form method=Post action=&quot;search.asp&quot;>
<div align=&quot;right&quot;><span class=&quot;style51&quot;><font color=&quot;#000080&quot;
size=&quot;2&quot;>共有<%=rs.recordcount%>条纪录 分为<%=rs.PageCount%>页 此为第<%=page%>页
<%if page>1 then
%>
<a href=&quot;search.asp?Page=<%=1%>&quot;>首页</a>
<a href=&quot;search.asp?Page=<%=page-1%>&quot;>上一页</a>
<%end if %>
<%if page<>rs.pagecount then
%>
<a href=&quot;search.asp?Page=<%=page+1%>&quot;>下一页</a>
<a href=&quot;search.asp?Page=<% = rs.PageCount%>&quot;>尾页</a>
<% end if %>
转到:</font> <font size=&quot;2&quot;>
<input type=&quot;text&quot;
name=&quot;page&quot;
size=&quot;4&quot;
maxlength=&quot;10&quot;
value=&quot;<%=page%>&quot;>
</font></span> <font size=&quot;2&quot;>
<input type=&quot;submit&quot;
value=&quot;
Goto &quot;
name=&quot;cndok&quot;>
</font></div>
</form>
</div></td>
</tr>
</table></TD>
</TR>
<TR align=&quot;left&quot;
valign=&quot;top&quot;>
<TD height=&quot;50&quot;
COLSPAN=2><div style=&quot;padding-left:2px;
padding-top:0px&quot;>
<TABLE cellSpacing=0 cellPadding=0 width=782 border=0>
<TBODY>
<TR>
<TD width=&quot;782&quot;
height=32 vAlign=center><TABLE height=&quot;91%&quot;
cellSpacing=0 cellPadding=0 width=779
border=0>
<TBODY>
<TR>
<TD width=537 vAlign=middle background=&quot;images/bg_bot.gif&quot;
bgcolor=&quot;#FFFFFF&quot;><FONT
style=&quot;FONT-WEIGHT: bold;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
COLOR: #ff0000&quot;>|<a href=&quot;html/help%20center.htm&quot;>&amp;nbsp;</a><A
style=&quot;FONT-WEIGHT: bold;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
COLOR: #ff0000&quot;
href=&quot;html/help%20center.htm?nowmenuid=306&quot;
target=_self>购物方式</A>&amp;nbsp;|&amp;nbsp;<A
style=&quot;FONT-WEIGHT: bold;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
COLOR: #ff0000&quot;
href=&quot;html/delivery.htm?nowmenuid=306&quot;
target=_self>送货方式</A>&amp;nbsp;|&amp;nbsp;<A
style=&quot;FONT-WEIGHT: bold;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
COLOR: #ff0000&quot;
href=&quot;html/payment.htm?nowmenuid=308&quot;
target=_self>付款方式</A>&amp;nbsp;|&amp;nbsp;<A
style=&quot;FONT-WEIGHT: bold;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
COLOR: #ff0000&quot;
href=&quot;html/replace.htm?nowmenuid=309&quot;
target=_self>退换原则</A>&amp;nbsp;|&amp;nbsp;<A
style=&quot;FONT-WEIGHT: bold;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
COLOR: #ff0000&quot;
href=&quot;html/servic%20guarantee.htm?nowmenuid=310&quot;
target=_self>服务保证</A>&amp;nbsp;| <A
style=&quot;FONT-WEIGHT: bold;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
COLOR: #ff0000&quot;
href=&quot;html/afterservice.htm?nowmenuid=310&quot;
target=_self>售后服务</A> | <A
style=&quot;FONT-WEIGHT: bold;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
COLOR: #ff0000&quot;
href=&quot;html/gather%20cents.htm?nowmenuid=310&quot;
target=_self>积分奖励</A> |</FONT></TD>
</TR>
</TBODY>
</TABLE></TD>
</TR>
<TR>
<TD valign=&quot;top&quot;><P align=center><FONT style=&quot;FONT-SIZE: 9pt&quot;
color=#1e578a> 青岛玉网 Copyright 2004-2005 All Rights Reserved. <img src=&quot;images/1106908023.gif&quot;
width=&quot;27&quot;
height=&quot;29&quot;></FONT></P>
</TD>
</TR>
</TBODY>
</TABLE>
</div></TD>
</TR>
</TABLE>
<!-- End ImageReady Slices -->
</body>
</html>
<%
conn.close
set conn=nothing
set rs=nothing
%>
 
比如数据库中每个表由10条记录,每页我设置显示5条。问题是现在第一页好好的。第二页竟然是空的了。应该有剩下5条才对啊。为了保持代码完整性,我全部粘贴上来了。大家可以模拟建一个数据库。把代码贴到自己机子上运行看看。用select * form 某个表就好好的,一点问题没有。可是我要搜索的是六个表(每个表结构完全一样,就是数据不同。)中p_type=&quot;aa&quot;的记录。就是多表查询,如果是单表,那么分页正常。
多表查询到第二页就没记录了。到底是什么回事?或者大家有更好的多表+asp分页查询显示也可以写上来告诉我。
谢谢大家了,那么热的天。
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;
&quot;http://www.w3.org/TR/html4/loose.dtd&quot;>
<html>
<head>
<%
Set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
strcon=&quot;provider=microsoft.jet.oledb.4.0;data source=&quot;&amp;
_
server.mappath(&quot;database/product.mdb&quot;)
conn.Open strcon
Set rs = Server.CreateObject (&quot;ADODB.Recordset&quot;)

SQL=&quot;select * from 陈设藏品 where p_type='&quot;&amp;request.Form(&quot;select&quot;)&amp;&quot;' union all select * from 挂件生肖 where p_type='&quot;&amp;request.Form(&quot;select&quot;)&amp;&quot;' union all select * from 汽车内饰 where p_type='&quot;&amp;request.Form(&quot;select&quot;)&amp;&quot;' union all select * from 生活保健 where p_type='&quot;&amp;request.Form(&quot;select&quot;)&amp;&quot;' union all select * from 首饰手镯 where p_type='&quot;&amp;request.Form(&quot;select&quot;)&amp;&quot;' union all select * from 文房四宝 where p_type='&quot;&amp;request.Form(&quot;select&quot;)&amp;&quot;'&quot;
rs.Open sql, conn, 1
rs.PageSize = 5 '每页显示记录数
if Not IsEmpty(Request(&quot;Page&quot;)) then
'如果PAGE已经初始化...
Page = CInt(Request(&quot;Page&quot;)) '接收PAGE并化为数字型赋给PAGE变量
if Page > rs.PageCount then
'如果接收的页数大于总页数
page=Rs.pageCount
rs.AbsolutePage = rs.PageCount '设置当前显示页等于最后页
else
rs.AbsolutePage = Page '显示当前页等于接收的页数
end if
else

Page = 1 '如果page未被初始化则设为1
End if
rs.AbsolutePage=page
%>
<meta http-equiv=&quot;Content-Type&quot;
content=&quot;text/html;
charset=gb2312&quot;>
<title>青岛玉网主页</title>
<style type=&quot;text/css&quot;>
<!--
.style17 { font-size: 12px;
font-weight: bold;
color: #51588c;
font-family: &quot;宋体&quot;;
}
.style22 { font-family: &quot;宋体&quot;;
font-size: 12px;
color: #6666FF;
}
.style5 { font-family: tahoma;
font-size: 11px;
color: #ff7800;
}
.style7 {color: #767676}
.input { BORDER-RIGHT: #000000 1px solid;
PADDING-RIGHT: 2px;
BORDER-TOP: #000000 1px solid;
PADDING-LEFT: 2px;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
PADDING-BOTTOM: 2px;
BORDER-LEFT: #000000 1px solid;
COLOR: #000000;
PADDING-TOP: 2px;
BORDER-BOTTOM: #000000 1px solid
}
.style36 {color: #FFFFFF;
font-family: &quot;宋体&quot;;
font-size: 12px;
}
.style37 {color: #FF3366}
.style46 {font-family: &quot;宋体&quot;;
font-size: 14px;
color: #6666FF;
}
.style48 {color: #FF3366;
font-size: 12px;
}
.style49 {color: #0033CC}
-->
</style>
<link href=&quot;CSS/text%20link.css&quot;
rel=&quot;stylesheet&quot;
type=&quot;text/css&quot;>
<style type=&quot;text/css&quot;>
<!--
.style50 {color: #FFFFFF}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
color: #cc66cc;
}
a:active {
text-decoration: none;
}
-->
</style>
</head>
<body>
<!-- ImageReady Slices (main.psd) -->
<TABLE WIDTH=780 height=&quot;164%&quot;
BORDER=0 align=&quot;center&quot;
CELLPADDING=0 CELLSPACING=0>
<TR align=&quot;left&quot;
valign=&quot;top&quot;>
<TD COLSPAN=2><table width=&quot;780&quot;
border=&quot;0&quot;
cellspacing=&quot;0&quot;
cellpadding=&quot;0&quot;>
<tr bgcolor=&quot;#CACDDF&quot;>
<td height=&quot;4&quot;
align=&quot;left&quot;
valign=&quot;top&quot;><img src=&quot;file:///C|/Documents%20and%20Settings/sj/&amp;#26700;&amp;#38754;/&amp;#27169;&amp;#26495;/&amp;#27431;&amp;#32654;&amp;#21830;&amp;#21153;&amp;#39764;&amp;#26495;/web_057/Html/images/spacer.gif&quot;
width=&quot;1&quot;
height=&quot;4&quot;></td>
</tr>
<tr>
<td align=&quot;left&quot;
valign=&quot;top&quot;><table width=&quot;779&quot;
height=&quot;39&quot;
border=&quot;0&quot;>
<tr>
<td width=&quot;189&quot;
height=&quot;35&quot;
valign=&quot;middle&quot;><div align=&quot;left&quot;><span class=&quot;style37&quot;>客服热线:0532-88888888</span></div></td>
<td width=&quot;0&quot;
height=&quot;35&quot;><table width=&quot;583&quot;
border=&quot;0&quot;>
<tr>
<td width=&quot;30&quot;><img src=&quot;images/happyking_05.jpg&quot;
width=&quot;27&quot;
height=&quot;27&quot;></td>
<td width=&quot;70&quot;
valign=&quot;middle&quot;><SPAN style=&quot;FONT-SIZE: 9pt&quot;><A
href=&quot;http://www.ehaier.com/jsp/cart/CartList.jsp&quot;><FONT
color=#ff0066>我的购物车</FONT></A></SPAN></td>
<td width=&quot;30&quot;><img src=&quot;images/happyking_09.jpg&quot;
width=&quot;27&quot;
height=&quot;27&quot;
align=&quot;top&quot;></td>
<td width=&quot;56&quot;
valign=&quot;middle&quot;><FONT color=#ff0066><SPAN
style=&quot;FONT-SIZE: 9pt&quot;><A
href=&quot;http://www.ehaier.com/sysstatic/flow_demo.jsp&quot;><FONT
color=#ff0066>购物指南</FONT></A></SPAN></FONT></td>
<td width=&quot;31&quot;><img src=&quot;images/happyking_11.jpg&quot;
width=&quot;27&quot;
height=&quot;27&quot;
align=&quot;top&quot;></td>
<td width=&quot;42&quot;
valign=&quot;middle&quot;><A
href=&quot;guestbook/index.asp&quot;><FONT
color=#ff0066><SPAN
style=&quot;FONT-SIZE: 9pt&quot;>留言板</SPAN></FONT></A></td>
<td width=&quot;287&quot;><form name=&quot;form1&quot;
method=&quot;post&quot;
action=&quot;&quot;>
<table width=&quot;294&quot;
border=&quot;0&quot;>
<tr>
<td width=&quot;44&quot;><div align=&quot;right&quot;><img src=&quot;images/search1.gif&quot;
width=&quot;20&quot;
height=&quot;16&quot;></div></td>
<td width=&quot;62&quot;
valign=&quot;middle&quot;><span class=&quot;style22&quot;>商品搜索</span></td>
<td width=&quot;102&quot;><select name=&quot;select&quot;>
<option>玉镯</option>
<option>项链</option>
<option>生肖</option>
<option>手球</option>
<option>玉印</option>
<option>玉枕</option>
<option>玉席玉垫</option>
<option>摆设</option>
</select></td>
<td width=&quot;57&quot;><img src=&quot;images/go1.gif&quot;
width=&quot;19&quot;
height=&quot;19&quot;
border=&quot;0&quot;>
</td>
</tr>
</table>
</form></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td width=&quot;0&quot;
align=&quot;left&quot;
valign=&quot;top&quot;><table width=&quot;100%&quot;
height=&quot;94&quot;
border=&quot;0&quot;>
<tr>
<td><span class=&quot;style37&quot;><img src=&quot;images/logo%20copy.gif&quot;
width=&quot;140&quot;
height=&quot;60&quot;></span></td>
<td><img src=&quot;images/gridflux800.jpg&quot;
width=&quot;633&quot;
height=&quot;88&quot;></td>
</tr>
</table></td>
</tr>
<tr>
<td height=&quot;0&quot;
align=&quot;left&quot;
valign=&quot;top&quot;><div align=&quot;center&quot;>
<table width=&quot;777&quot;
border=&quot;0&quot;
cellspacing=&quot;0&quot;
cellpadding=&quot;0&quot;>
<tr>
<td width=&quot;777&quot;
height=&quot;26&quot;
align=&quot;left&quot;
valign=&quot;top&quot;
bgcolor=&quot;#FFFFFF&quot;><table width=&quot;776&quot;
height=&quot;28&quot;
border=&quot;0&quot;>
<tr background=&quot;images/menu.jpg&quot;>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style37 style36&quot;><a href=&quot;index.asp&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>首页</a></div></td>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;search.asp&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>首饰/手镯</a></div></td>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;guashi.asp&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>挂件/生肖</a></div></td>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;life.asp&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>生活/保健</a></div></td>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;wenfang.asp&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>文房四宝</a></div></td>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;car.asp&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>汽车内饰</a></div></td>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;layout.asp&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>陈设藏品</a></div></td>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;html/maintain.htm&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>玉的保养</a></div></td>
<td width=&quot;73&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;html/culture.htm&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>玉的文化</a></div></td>
<td width=&quot;77&quot;
background=&quot;images/menu.jpg&quot;><div align=&quot;center&quot;
class=&quot;style36&quot;><a href=&quot;html/introduce.htm&quot;
target=&quot;_self&quot;
class=&quot;style50&quot;>玉网简介</a></div></td>
</tr>
</table></td>
</tr>
</table>
<table width=&quot;778&quot;
border=&quot;0&quot;>
<tr>
<td width=&quot;487&quot;><div align=&quot;left&quot;>
<table width=&quot;588&quot;
height=&quot;21&quot;
border=&quot;0&quot;>
<tr>
<td width=&quot;352&quot;
class=&quot;style17&quot;>您的位置:首页</td>
<td width=&quot;778&quot;
class=&quot;style37&quot;>祝您在青岛玉网购物愉快!</td>
</tr>
</table>
</div></td>
</tr>
</table>
</div></td>
</tr>
</table>
</TD>
</TR>
<TR>
<TD width=&quot;0&quot;
align=&quot;left&quot;
valign=&quot;top&quot;><div style=&quot;padding-left:0px;
padding-bottom:5px&quot;>
<table width=&quot;98%&quot;
height=&quot;30%&quot;
border=&quot;0&quot;>
<tr>
<td width=&quot;233&quot;
height=&quot;30&quot;
align=&quot;center&quot;
valign=&quot;middle&quot;
background=&quot;images/kettle_2.gif&quot;><div align=&quot;center&quot;
class=&quot;style46&quot;>会员登录</div></td>
</tr>
</table>
<table width=&quot;230&quot;
border=&quot;0&quot;
bordercolor=&quot;#CCCCCC&quot;>
<tr>
<td width=&quot;238&quot;
height=&quot;29&quot;><TABLE width=&quot;100%&quot;
align=left cellPadding=4 cellSpacing=1 bordercolor=&quot;#990033&quot;
bgColor=#ffffff>
<TBODY>
<TR>
<TD align=middle colSpan=2 height=5></TD>
</TR>
<FORM action=admin.php method=post>
<TR>
<TD style=&quot;FONT-SIZE: 12px;
COLOR: #000000&quot;
align=middle
width=&quot;43%&quot;
height=22><div align=&quot;center&quot;>会员名:</div></TD>
<TD width=&quot;57%&quot;
height=22><div align=&quot;center&quot;>
<INPUT class=input
maxLength=20 size=11 name=muser>
</div></TD>
</TR>
<TR>
<TD style=&quot;FONT-SIZE: 12px;
COLOR: #000000&quot;
align=middle
width=&quot;43%&quot;
height=22><div align=&quot;center&quot;>密 码:</div></TD>
<TD width=&quot;57%&quot;
height=22><div align=&quot;center&quot;>
<INPUT class=input
type=password maxLength=20 size=11 name=mpass>
</div></TD>
</TR>
<TR>
<TD align=right height=20><a href=&quot;user_registration.asp&quot;><img src=&quot;images/zc.jpg&quot;
width=&quot;74&quot;
height=&quot;32&quot;
border=&quot;0&quot;
align=&quot;baseline&quot;></a> </TD>
<TD vAlign=top height=20><div align=&quot;center&quot;><img src=&quot;images/dl2.jpg&quot;
width=&quot;74&quot;
height=&quot;31&quot;></div></TD>
</FORM>
</TABLE></td>
</tr>
<tr>
<td height=&quot;355&quot;
valign=&quot;top&quot;><div align=&quot;left&quot;>
<table width=&quot;100%&quot;
height=&quot;234&quot;
border=&quot;0&quot;
bordercolor=&quot;#FFFFFF&quot;>
<tr>
<td width=&quot;237&quot;
height=&quot;30&quot;
background=&quot;images/kettle_1.gif&quot;><div align=&quot;center&quot;
class=&quot;style49&quot;>新品推荐</div></td>
</tr>
<tr>
<td height=&quot;198&quot;
valign=&quot;top&quot;>&amp;nbsp;</td>
</tr>
</table>
<table width=&quot;238&quot;
border=&quot;0&quot;>
<tr>
<td width=&quot;208&quot;
height=&quot;33&quot;
background=&quot;images/kettle_4.gif&quot;><div align=&quot;center&quot;
class=&quot;style46&quot;>
<p>客服中心</p>
</div></td>
</tr>
<tr>
<td height=&quot;133&quot;
valign=&quot;top&quot;
bordercolor=&quot;#CCCCCC&quot;><div align=&quot;center&quot;>
<p align=&quot;left&quot;
class=&quot;style48&quot;>您的任何疑问,我们将全力以赴为您解决!</p>
<p align=&quot;left&quot;
class=&quot;style48&quot;><span class=&quot;style49&quot;>客服热线</span><img src=&quot;images/1111485546.gif&quot;
width=&quot;20&quot;
height=&quot;20&quot;>:<span class=&quot;style49&quot;>0532-88888888 13888888888 </span></p>
<p align=&quot;left&quot;
class=&quot;style48&quot;><span class=&quot;style49&quot;>在线客服</span><img src=&quot;images/1106908031.gif&quot;
width=&quot;20&quot;
height=&quot;20&quot;>:<span class=&quot;style49&quot;>111111111</span></p>
<p align=&quot;left&quot;
class=&quot;style48&quot;><span class=&quot;style49&quot;>客服</span><img src=&quot;images/1111485629.gif&quot;
width=&quot;16&quot;
height=&quot;16&quot;>:<span class=&quot;style49&quot;>xxxx@xxx.com</span></p>
</div></td>
</tr>
</table>
</div></td>
</tr>
</table>
</div></TD>
<TD width=&quot;539&quot;
align=&quot;left&quot;
valign=&quot;top&quot;><table width=&quot;539&quot;
border=&quot;0&quot;
cellspacing=&quot;0&quot;
cellpadding=&quot;0&quot;>
<tr>
<td height=&quot;460&quot;
align=&quot;left&quot;
valign=&quot;top&quot;><div style=&quot;padding-left:14px;
padding-top:15px&quot;>
<div align=&quot;center&quot;><font size=&quot;2&quot;> <strong>
<%
i=0
response.Write(rs.recordcount)
do while not rs.eof
%>
</strong></font> </div>
<table width=&quot;600&quot;
border=&quot;0&quot;
ALIGN=&quot;CENTER&quot;>
<tr>
<td WIDTH=106><img src=&quot;<%=rs(&quot;pic_addr&quot;)%>&quot;
alt=&quot;&quot;
width=&quot;106&quot;
height=&quot;100&quot;></td>
<td WIDTH=98 valign=&quot;top&quot;
background=&quot;images/back_rep_2.gif&quot;><p><%=rs(&quot;product_name&quot;)%></p>
<p><span class=&quot;style5&quot;>市场价:<span class=&quot;style7&quot;>¥</span></span><%=rs(&quot;price&quot;)%></p>
<p><span class=&quot;style5&quot;>会员价:<span class=&quot;style7&quot;>¥</span></span><%=rs(&quot;vip_price&quot;)%></p></td>
<td WIDTH=382 valign=&quot;top&quot;
background=&quot;images/back_rep_2.gif&quot;><span class=&quot;style5&quot;><br>
<%=rs(&quot;introduction&quot;)%> </span></td>
</tr>
<tr background=&quot;images/back_rep_2.gif&quot;>
<td COLSPAN=&quot;4&quot;
align=&quot;center&quot;>&amp;nbsp;</td>
</tr>
</table>
<%
'当显示记录大于maxperpage时结束这页
i=i+1
IF i>=rs.PageSize then
exitdo

rs.movenext
loop
%>
<form method=Post action=&quot;search.asp&quot;>
<div align=&quot;right&quot;><span class=&quot;style51&quot;><font color=&quot;#000080&quot;
size=&quot;2&quot;>共有<%=rs.recordcount%>条纪录 分为<%=rs.PageCount%>页 此为第<%=page%>页
<%if page>1 then
%>
<a href=&quot;search.asp?Page=<%=1%>&quot;>首页</a>
<a href=&quot;search.asp?Page=<%=page-1%>&quot;>上一页</a>
<%end if %>
<%if page<>rs.pagecount then
%>
<a href=&quot;search.asp?Page=<%=page+1%>&quot;>下一页</a>
<a href=&quot;search.asp?Page=<% = rs.PageCount%>&quot;>尾页</a>
<% end if %>
转到:</font> <font size=&quot;2&quot;>
<input type=&quot;text&quot;
name=&quot;page&quot;
size=&quot;4&quot;
maxlength=&quot;10&quot;
value=&quot;<%=page%>&quot;>
</font></span> <font size=&quot;2&quot;>
<input type=&quot;submit&quot;
value=&quot;
Goto &quot;
name=&quot;cndok&quot;>
</font></div>
</form>
</div></td>
</tr>
</table></TD>
</TR>
<TR align=&quot;left&quot;
valign=&quot;top&quot;>
<TD height=&quot;50&quot;
COLSPAN=2><div style=&quot;padding-left:2px;
padding-top:0px&quot;>
<TABLE cellSpacing=0 cellPadding=0 width=782 border=0>
<TBODY>
<TR>
<TD width=&quot;782&quot;
height=32 vAlign=center><TABLE height=&quot;91%&quot;
cellSpacing=0 cellPadding=0 width=779
border=0>
<TBODY>
<TR>
<TD width=537 vAlign=middle background=&quot;images/bg_bot.gif&quot;
bgcolor=&quot;#FFFFFF&quot;><FONT
style=&quot;FONT-WEIGHT: bold;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
COLOR: #ff0000&quot;>|<a href=&quot;html/help%20center.htm&quot;>&amp;nbsp;</a><A
style=&quot;FONT-WEIGHT: bold;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
COLOR: #ff0000&quot;
href=&quot;html/help%20center.htm?nowmenuid=306&quot;
target=_self>购物方式</A>&amp;nbsp;|&amp;nbsp;<A
style=&quot;FONT-WEIGHT: bold;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
COLOR: #ff0000&quot;
href=&quot;html/delivery.htm?nowmenuid=306&quot;
target=_self>送货方式</A>&amp;nbsp;|&amp;nbsp;<A
style=&quot;FONT-WEIGHT: bold;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
COLOR: #ff0000&quot;
href=&quot;html/payment.htm?nowmenuid=308&quot;
target=_self>付款方式</A>&amp;nbsp;|&amp;nbsp;<A
style=&quot;FONT-WEIGHT: bold;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
COLOR: #ff0000&quot;
href=&quot;html/replace.htm?nowmenuid=309&quot;
target=_self>退换原则</A>&amp;nbsp;|&amp;nbsp;<A
style=&quot;FONT-WEIGHT: bold;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
COLOR: #ff0000&quot;
href=&quot;html/servic%20guarantee.htm?nowmenuid=310&quot;
target=_self>服务保证</A>&amp;nbsp;| <A
style=&quot;FONT-WEIGHT: bold;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
COLOR: #ff0000&quot;
href=&quot;html/afterservice.htm?nowmenuid=310&quot;
target=_self>售后服务</A> | <A
style=&quot;FONT-WEIGHT: bold;
FONT-SIZE: 12px;
BACKGROUND: #ffffff;
COLOR: #ff0000&quot;
href=&quot;html/gather%20cents.htm?nowmenuid=310&quot;
target=_self>积分奖励</A> |</FONT></TD>
</TR>
</TBODY>
</TABLE></TD>
</TR>
<TR>
<TD valign=&quot;top&quot;><P align=center><FONT style=&quot;FONT-SIZE: 9pt&quot;
color=#1e578a> 青岛玉网 Copyright 2004-2005 All Rights Reserved. <img src=&quot;images/1106908023.gif&quot;
width=&quot;27&quot;
height=&quot;29&quot;></FONT></P>
</TD>
</TR>
</TBODY>
</TABLE>
</div></TD>
</TR>
</TABLE>
<!-- End ImageReady Slices -->
</body>
</html>
<%
conn.close
set conn=nothing
set rs=nothing
%>
 
没人知道吗?
 
你将语句在Access中执行看看结果是什么
 
<select name=&quot;select&quot;>
<option>玉镯</option>
<option>项链</option>
<option>生肖</option>
<option>手球</option>
<option>玉印</option>
<option>玉枕</option>
<option>玉席玉垫</option>
<option>摆设</option>
</select>
其中不要指定value吗?如果没有,传递过来的值是什么?
我这里不好试,只好猜一下.
首先确定你的语句执行结果是正确的,比如检索出来的条数.
还有,没必要把源码全部都贴上来吧?
 
后退
顶部