asp实现表格3列5行
网络编程 2021-07-05 10:58www.168986.cn编程入门
方案一
方案二、
上面的代码有缺点..
就是如果是 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>")
这样页面才完整的
代码如下:
<!--#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>
<%
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>
<%
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>")
这样页面才完整的
编程语言
- 如何快速学会编程 如何快速学会ug编程
- 免费学编程的app 推荐12个免费学编程的好网站
- 电脑怎么编程:电脑怎么编程网咯游戏菜单图标
- 如何写代码新手教学 如何写代码新手教学手机
- 基础编程入门教程视频 基础编程入门教程视频华
- 编程演示:编程演示浦丰投针过程
- 乐高编程加盟 乐高积木编程加盟
- 跟我学plc编程 plc编程自学入门视频教程
- ug编程成航林总 ug编程实战视频
- 孩子学编程的好处和坏处
- 初学者学编程该从哪里开始 新手学编程从哪里入
- 慢走丝编程 慢走丝编程难学吗
- 国内十强少儿编程机构 中国少儿编程机构十强有
- 成人计算机速成培训班 成人计算机速成培训班办
- 孩子学编程网上课程哪家好 儿童学编程比较好的
- 代码编程教学入门软件 代码编程教程