按列显示数据表中字段的值

王朝other·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

在织梦论坛看到有很多会员提到如何通过循环do while调用数据表字段的问题。网上也见过这种方法很多,但感觉都挺复杂的,有的都动用Mod运算符进行取余运算了。包括我自己,在实际工作中实现效果也有点过于复杂了。试着改用一下分列显示的效果(分列显示效果见下图),感觉代码简练了好多,而且易于初学asp的用户修改。

代码如下:

<%

'绑定数据库Conn,略......

Set rs = Conn.Execute("select top 7 ID from news order by ID asc")

if not(rs.eof and rs.bof) then

response.write "<table width=""80%"" border=""1"">" & Chr(10)

do while not rs.eof

response.write " <tr width=""20%"">" & Chr(10)

for i=1 to 4

response.write " <td>"

if not rs.eof then

response.write rs("ID")

rs.movenext

else

response.write "."

end if

response.write "</td>" & Chr(10)

next

response.write " </tr>" & Chr(10)

loop

response.write "</table>"

else

response.write "未有记录......"

end if

rs.close : set rs = nothing

%>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有  導航