当前位置: 首页 > 图文教程 > 网络编程 > ASP > asp实现表格3列5行

ASP
随机提取Access/SqlServer数据库中的10条记录的SQL语句
实现对Access数据库表重命名的一段代码
XML+XSL+CSS+ASP打造留言簿
小偷&小偷入库&采集入库
使用asp代码突破163相册的防盗连
CJJ专用ASP类库中的某个class
能不能在flash动画中给asp传递变量?
禁止站外提交表单
改进一下asp自带的formatNumber函数
收集asp的常用函数
CHR(10)表示换行,CHR(13)表示回车,CHR(32)表示空格
ASP 指南
pjblog2的参数
ASP智能搜索的实现
网站生成静态页面攻略2:数据采集
网站生成静态页面攻略3:防采集策略
网站生成静态页面攻略4:防采集而不防搜索引擎策略
简单分页函数一 常用
asp最常用的分页函数
asp:生成静态页面函数

ASP 中的 asp实现表格3列5行


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 41 ::
收藏到网摘: n/a

方案一
复制代码 代码如下:
<!--#include file="conn.asp"-->
<%
owen1=request("owen1")
owen2=request("owen2")
%>

<table width="95%" border="0" cellpadding="0" cellspacing="0">
<%
page=clng(request("page"))
Set rs=Server.CreateObject("ADODB.RecordSet")
if owen1<>"" and owen2 <>"" then
sql="select * from news where BigClassName='"&owen1&"' and SmallClassName='"&owen2&"' order by id desc"
rs.Open sql,conn,1,1
elseif owen1<>"" then
sql="select * from news where BigClassName='"&owen1&"' order by id desc"
rs.Open sql,conn,1,1
end if
if rs.eof and rs.bof then
response.Write("暂时没有记录")
else
%>
<%
rs.PageSize=15
if page=0 then page=1
pages=rs.pagecount
if page > pages then page=pages
rs.AbsolutePage=page
for j=1 to rs.PageSize
if (j-1) mod 3=0 then Response.Write("<tr>")
%>
<td height="24" align="center" > 
<div align="center"><img src="uppic/<%= RS("firstImageName") %>"width="130" height="100" border="0" /><a href="onews.asp?id=<%= RS("id") %>" target="_blank"><br>
<%= RS("TITLE") %></a></div></td>
<%
if j mod 3=0 then Response.Write("</tr>")
rs.movenext
if rs.eof then exit for
next
%>
<%
end if
rs.close
set rs=nothing
%>
</table>

方案二、
复制代码 代码如下:
<!--#include file="conn.asp"-->
<%
owen1=request("owen1")
owen2=request("owen2")
%>

<table width="95%" border="0" cellpadding="0" cellspacing="0">
<%
page=clng(request("page"))
Set rs=Server.CreateObject("ADODB.RecordSet")
if owen1<>"" and owen2 <>"" then
sql="select * from news where BigClassName='"&owen1&"' and SmallClassName='"&owen2&"' order by id desc"
rs.Open sql,conn,1,1
elseif owen1<>"" then
sql="select * from news where BigClassName='"&owen1&"' order by id desc"
rs.Open sql,conn,1,1
end if
if rs.eof and rs.bof then
response.Write("暂时没有记录")
else
%>
<%
rs.PageSize=15
if page=0 then page=1
pages=rs.pagecount
if page > pages then page=pages
rs.AbsolutePage=page
for j=1 to (rs.PageSize/3)
Response.Write("<tr>")
for i=1 to 3
%>
<td height="24" align="center" > 
<div align="center"><img src="uppic/<%= RS("firstImageName") %>"width="130" height="100" border="0" /><a href="onews.asp?id=<%= RS("id") %>" target="_blank"><br>
<%= RS("TITLE") %></a></div></td>
<%
rs.movenext
if rs.eof then exit for
next
Response.Write("</tr>")
next
%>
<%
end if
rs.close
set rs=nothing
%>
</table>

上面的代码有缺点..
就是如果是 16条 那么页面最后一行会空出两列 页面很难看 因为如果16 最后一行只显示一列 这样少了两个<td></td> 
必须进行判断 总数/3的余数
if (rs.recordcount mod 3=2) then response.write("<td> </td>")
if (rs.recordcount mod 3=1) then response.write("<td> </td><td> </td>")
这样页面才完整的