ASP中多列显示信息

要想显示美观可以自己设置样式
<%
dim maxCount '希望显示的信息数
maxCount=10
dim lineCount '希望一行显示的信息数
lineCount=4
'判断数据库中现有信息的条数
sql="select * from News where BigClassName='公司动态'"
set rs=server.CreateObject("ADODB.recordset")
rs.open sql,conn,1,1
dim rc
rc=rs.Recordcount

response.Write("<table width='1000' height='500' border='0'>")


'判断数据库中的数据是否比maxCount少,少了就显示在一行中
if rc <= lineCount then
response.Write("<tr>")
do while not rs.eof
response.Write("<td>"&rs("Title")&"</td>")
rs.movenext
loop
response.Write("</tr>")
rs.close
set rs=nothing

'数据库中的数据大于maxCount
else
dim fuzhu
fuzhu=0
rs.close
set rs=nothing
sql1="select top "& maxCount &" * from News where BigClassName='公司动态'"
set rs1=server.CreateObject("ADODB.recordset")
rs1.open sql1,conn,1,1

response.Write("<tr>")
do while not rs1.eof
if fuzhu mod lineCount=0  then
response.Write("</tr><tr>")
end if
response.Write("<td>"&rs1("Title")&"</td>")
fuzhu=fuzhu+1
rs1.movenext

loop
rs1.close
set rs1=nothing
response.Write("</tr>")


end if

response.Write("</table>")
%>

转载于:https://www.cnblogs.com/miaochaosong/archive/2007/09/15/893952.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值