asp实现表格3列5行

所属分类: 网络编程 / ASP编程 阅读数: 1379
收藏 0 赞 0 分享
方案一
复制代码 代码如下:
<!--#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>&nbsp;</td>")
if (rs.recordcount mod 3=1) then response.write("<td>&nbsp;</td><td>&nbsp;</td>") 

这样页面才完整的
更多精彩内容其他人还在看

asp中去除内容HTML标签的三个function函数

asp中去除内容HTML标签的三个function函数
收藏 0 赞 0 分享

chr(9)、chr(10)、chr(13)、chr(32)、chr(34)讲解

chr(9)、chr(10)、chr(13)、chr(32)、chr(34)讲解
收藏 0 赞 0 分享

方便的大家admin及admin888 经过 md5加密后16位和32位代码

方便的大家admin及admin888 经过 md5加密后16位和32位代码
收藏 0 赞 0 分享

可用的ASP无重复数字随机函数, 数组实现, 并应用于随机显示记录集

可用的ASP无重复数字随机函数, 数组实现, 并应用于随机显示记录集
收藏 0 赞 0 分享

asp动态级联菜单代码

asp动态级联菜单代码
收藏 0 赞 0 分享

ASP中经常使用的SQL语句与教程说明

ASP中经常使用的SQL语句与教程说明
收藏 0 赞 0 分享

实例分析之用ASP编程实现网络内容快速查找的代码

实例分析之用ASP编程实现网络内容快速查找的代码
收藏 0 赞 0 分享

服务端 VBScript 与 JScript 几个相同特性的写法与示例

服务端 VBScript 与 JScript 几个相同特性的写法与示例
收藏 0 赞 0 分享

ASP 环境下 VBS 事件应用 示例代码

ASP 环境下 VBS 事件应用 示例代码
收藏 0 赞 0 分享

asp 之上传漏洞终结篇

asp 之上传漏洞终结篇
收藏 0 赞 0 分享
查看更多