注册 登录
编程论坛 ASP技术论坛

变量有多个逗号隔开如何逐个提取

luyishi 发布于 2017-03-08 16:19, 2005 次点击
数据库表Result
id   remark
1   a, b, c, 1, 2, 3
.      .
.      .
30   123, 我, n, ,b, 9
查询显示remark并且每行逐个,如:
a
b
c
1
2
3
代码如下:
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/config.asp"-->
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>123</title>
<link href="images/index.css" rel="stylesheet" type="text/css">
</head>
<body>
<%
    dim str
    dim strs()
    dim tempstr
     set rs=server.createobject("adodb.recordset")
    sql="select * from Result where id =30  "  
    rs.open sql,conn,1,1
    do while not rs.eof
%>
<%
  rs.movenext
  loop
  rs.close
  set rs=nothing
%>
<%
str=rs("remark")
strs=split(str,",")
for i=0 to strs
response.write strs(i)
next
%>
</body>
</html>
求指点,谢谢!
1 回复
#2
ke爱的小tu子2021-02-11 14:28
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/config.asp"-->
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>123</title>
<link href="images/index.css" rel="stylesheet" type="text/css">
</head>
<body>
<%
    dim str
    dim strs()
    dim tempstr
     set rs=server.createobject("adodb.recordset")
    sql="select * from Result where id =30  "  
    rs.open sql,conn,1,1
    do while true
        if rs.eof or rs.bof then
            exit do
        end if

        str=rs("remark")
        strs=split(str,",")
        for i=0 to ubound(strs)
            response.write strs(i)&"<br>"
        next
      rs.movenext
  loop
  rs.close
  set rs=nothing
%>
</body>
</html>
1