ASP分隔符循环问题

来源:百度知道 编辑:UC知道 时间:2024/06/02 14:40:29
id=12,15,180

set rs=server.CreateObject("adodb.recordset")
sql="select top 3 * from xinx where tj=true and id="&id&" order by tgpx desc"
rs.open sql,conn,1,1

上面的ID字段是以,分隔出来的,我要怎么循环显示出个12的内容和15的内容,和180的内容呢

cid=split(id)
did="(id="&cid(0)&" or id="&cid(1)&" or id="&cid(2)&")"
上面添加
============================
sql="select top 3 * from xinx where tj=true and id="&id&" order by tgpx desc"
改成
sql=sql="select top 3 * from xinx where tj=true and "&did&" order by tgpx desc"

循环输出

do while not rs.eof
response.write rs("id")
rs.movenext
loop

Split()

函数将一个字符串分割并返回分割结果

表达式 Split (S[,d])

实例:<%V= Split(A,B,C)

For i = 0 To UBound(V)

Response.Write V(i)

Next

%>

返回结果: A B C

用split函数把ID切分成数组。