分页的问题
有一个sql server 的数据库,里边存放有不同类型的数据,而某一类型的数据由若干张表组成,不同类型的数据的表结构不同,同一类型的数据的表结构相同,如果实现可以跨不同数据类型的表进行检索,并把数据分页显示出来.
其中有一张表存放所有表的名称.
<%dim xueming,zhongwenming,leibei
zhongwenming=Request("zhongwenming")
xueming=Request("xueming")
leibei=Request("leibei")
%>
<% lanmu="xjml"
Set rs1=Server.CreateObject("ADODB.RecordSet")
sql2="select * from sjk where sjkm like '%"&lanmu&"%' "
rs1.open sql2,conn,1,1
do while not rs1.eof
sjkm1=rs1("sjkm")
if not isempty(request("page")) then
pagecount=cint(request("page"))
else
pagecount=1
end if
Set rs=Server.CreateObject("ADODB.RecordSet")
sql="SELECT * FROM "& sjkm1&" "
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write"<SCRIPT language=JavaScript>alert('对不起,没有符合搜索条件的记录!');"
response.write"javascript:window.close();</SCRIPT>"
end if
rs.pagesize=10
if pagecount>rs.pagecount or pagecount<=0 then
pagecount=1
end if
rs.AbsolutePage=pagecount %> <table width="770" align="center" background="images/serch.jpg" >
<tr>
<td height="96" valign="top"> <div align="center"><br>
<br>
<span class="style51"><br>
<br>
<%else%>
<% page_start=(pagecount-1)*rs.pagesize
if pagecount=1 then page_start=1
page_end=rs.pagesize*pagecount
if pagecount*rs.pagesize=>rs.recordcount then page_end=rs.recordcount end if%>
共有[ <font color="#ff0000"><%=rs.recordcount%></font> ] 条符合条件。 以下是[<font color="red"><%=page_start%>~<%=page_end%></font>]条</font></td>
<tr>
<td height="6" colspan="4" valign="bottom">
<% response.write"<form name=go2to form method=Post action='search.asp?zhongwenming="+zhongwenming+"&xueming="+xueming+"&leibei="+leibei+"'>"
response.write "<font color='#000064'</font>"
if pagecount=1 then
response.write "<font color='#000064'> 首页 上一页 </font> "
else
response.write "<a href=search.asp?page=1&zhongwenming="+zhongwenming+"&xueming="+xueming+"&leibei="+leibei+"><font color='0000BE'>首页</font></a> "
response.write "<a href=search.asp?page="+cstr(pagecount-1)+"&zhongwenming="+zhongwenming+"&xueming="+xueming+"&leibei="+leibei+"><font color='0000BE'>上一页</font></a> "
end if
if rs.PageCount-pagecount<1 then
response.write "<font color='#000064'> 下一页 尾页 </font>"
else
response.write "<a href=search.asp?page="+cstr(pagecount+1)+"&zhongwenming="+zhongwenming+"&xueming="+xueming+"&leibei="+leibei+"><font color='0000BE'>下一页</font></a> "
response.write "<a href=search.asp?page="+cstr(rs.PageCount)+"&zhongwenming="+zhongwenming+"&xueming="+xueming+"&leibei="+leibei+"><font color='0000BE'>尾页</font></a>"
end if
response.write "<font color='000064'> 页次:<font color=blue>"&pagecount&"</font>/"&rs.pagecount&"页</font>"
response.write "<font color='000064'> 转到第<input type='text' name='page' size=2 maxLength=3 style='font-size: 9pt; color:#00006A; position: relative; height: 18' value="&PageCount&">页</font> "
response.write "<input class=button type='button' value='确 定' onclick=check() style='font-family: 宋体; font-size: 9pt; color: #000073; position: relative; height: 19'>" %>
<br>
</td>
<% end if %>
</tr>
<tr >
<td height="4" colspan="4" valign="top"bgcolor="#FFFFFF"> </td>
</tr>
<tr class="style6">
<td width="74" height="25">
<div align="center" class="style7">
<p class="style8">编 号</p>
</div></td>
<td width="170"><div align="center" class="style7">
<p class="style8">菌 种 名 称</p>
</div></td>
<td width="380" height="25">
<div align="center" class="style7">
<p class="style8">拉 丁 学 名</p>
</div></td>
<td width="107" height="25"><p align="center" class="style7">原 编 号</p></td>
</tr>
<% do while not rs.eof %>
<tr class="style6">
<td width="74" height="27"><p align="center" class="style7"> <%=rs("sjk")%></p></td>
<td width="170" height="27"><p align="center" class="style7"><a href="#" class="style10" onClick="javascript:window.open('searchqk.asp?id=<%=rs("id")%>','InfoDetail','toolbar=no,scrollbars=yes,resizable=yes,top=20,left=20,width=629 height=450'); "><%=rs("zhongwenming")%></a></p></td>
<td width="380" height="27">
<p align="left" class="style7"><span class="style8"> <%=rs("xueming")%></span></p></td>
<td width="107" height="27"><p align="center" class="style7"><%=rs("yuanbianhao")%></p></td>
</tr>
<% i=i+1
rs.movenext
if i>=rs.PageSize then exit do
loop
rs.close
set rs=nothing
rs1.movenext
loop
rs1.close
set rs1=nothing
%>
<tr>
<td height="4" valign="top" colspan="4" bgcolor="#FFFFFF"> </td>
</tr>
</table> <div align="center"><span class="style51"><a href="jzcx.htm"><br>
重 新 查 询</a></span></div></td>
</tr>
</table> <div align="left">
<p> </p>
<br>
</div>
</body>
</html>