ASP中数组的使用

发布时间:2007-03-06 20:56:00 阅读:1348次

一维数组:

<!--#include file="conn.asp"-->
<%
dim a(2)
dim i
i=0
set rs=conn.execute("select *from forum")
do while not rs.eof
a(i)="<item><id>"&rs("userhome")&"</id></item>"
i=i+1
rs.movenext
loop%>
<%response.write i&"<br>"%>
<%for j=0 to i-1%>
<%response.write a(j)&"<br>"%>
<%next%>


<%
dim B
B=array ("1","2","3")
response.write B(2)
%>

 

二维数组:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>

<!--#include file="conn.asp"-->
<%
dim a(2,1)
set rs=server.CreateObject("adodb.recordset")
rs.open "select *from forum",conn,1,1
for i=0 to rs.recordcount-1
a(i,0)=rs("id")
a(i,1)=rs("userhome")
rs.movenext
next
%>
<%
  for j=0 to 2
  response.write a(j,0)
  response.write a(j,1)

  next
%>
</body>
</html>

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询
上一篇:生成XML文件

转载请注明:ASP中数组的使用 出自老鄢博客 | 欢迎分享