ASP嵌套循环如何取记录放入数组
DimcRs,cSqlsetcRs=server.CreateObject("adodb.Recordset")cSql="SELECT*FROMtkflwheretkf...
Dim cRs,cSql
set cRs=server.CreateObject("adodb.Recordset")
cSql="SELECT * FROM tkfl where tkfl_zy='"&ks_zy&"' order by tkfl_px"
cRs.Open cSql,oConn,1,1
Do while not cRs.eof
Dim lRs,lSql
Randomize
set lRs=server.CreateObject("adodb.Recordset")
lSql="SELECT top "&cRs("tkfl_ts")&" tk_id FROM tk where tk_lb="&cRs("tkfl_id")&" order by rnd(-(tk_id +" & rnd() & "))"
lRs.Open lSql,oConn,1,1
Do while not lRs.eof
%>
<tr>
<td><%=lRs("tk_id")%></td>
</tr>
<%
lRs.Movenext
loop
lRs.Close
set lRs=nothing
cRs.Movenext
loop
cRs.Close
set cRs=nothing
-----------------------------------------------------------------------
我想把列出的tk_id放入数组,该怎么写
比如现在读取的记录是
3
6
7
我想弄成这样3,6,7
并且这个记录数不是固定的
请高手回答,谢谢
这个只能列出子循环的,我想列出全部循环的?谢谢高手 展开
set cRs=server.CreateObject("adodb.Recordset")
cSql="SELECT * FROM tkfl where tkfl_zy='"&ks_zy&"' order by tkfl_px"
cRs.Open cSql,oConn,1,1
Do while not cRs.eof
Dim lRs,lSql
Randomize
set lRs=server.CreateObject("adodb.Recordset")
lSql="SELECT top "&cRs("tkfl_ts")&" tk_id FROM tk where tk_lb="&cRs("tkfl_id")&" order by rnd(-(tk_id +" & rnd() & "))"
lRs.Open lSql,oConn,1,1
Do while not lRs.eof
%>
<tr>
<td><%=lRs("tk_id")%></td>
</tr>
<%
lRs.Movenext
loop
lRs.Close
set lRs=nothing
cRs.Movenext
loop
cRs.Close
set cRs=nothing
-----------------------------------------------------------------------
我想把列出的tk_id放入数组,该怎么写
比如现在读取的记录是
3
6
7
我想弄成这样3,6,7
并且这个记录数不是固定的
请高手回答,谢谢
这个只能列出子循环的,我想列出全部循环的?谢谢高手 展开
2个回答
展开全部
已作修改,刚才一时大意
将tk_id放到strArr数组里
Dim cRs,cSql
str = ""
set cRs=server.CreateObject("adodb.Recordset")
cSql="SELECT * FROM tkfl where tkfl_zy='"&ks_zy&"' order by tkfl_px"
cRs.Open cSql,oConn,1,1
Do while not cRs.eof
Dim lRs,lSql
Randomize
set lRs=server.CreateObject("adodb.Recordset")
lSql="SELECT top "&cRs("tkfl_ts")&" tk_id FROM tk where tk_lb="&cRs("tkfl_id")&" order by rnd(-(tk_id +" & rnd() & "))"
lRs.Open lSql,oConn,1,1
Do while not lRs.eof
str = str&lRs("tk_id")&","
%>
<tr>
<td><%=lRs("tk_id")%></td>
</tr>
<%
lRs.Movenext
loop
lRs.Close
set lRs=nothing
cRs.Movenext
loop
cRs.Close
set cRs=nothing
str = left(str,int(len(str)-1))
strArr = split(str,",")
将tk_id放到strArr数组里
Dim cRs,cSql
str = ""
set cRs=server.CreateObject("adodb.Recordset")
cSql="SELECT * FROM tkfl where tkfl_zy='"&ks_zy&"' order by tkfl_px"
cRs.Open cSql,oConn,1,1
Do while not cRs.eof
Dim lRs,lSql
Randomize
set lRs=server.CreateObject("adodb.Recordset")
lSql="SELECT top "&cRs("tkfl_ts")&" tk_id FROM tk where tk_lb="&cRs("tkfl_id")&" order by rnd(-(tk_id +" & rnd() & "))"
lRs.Open lSql,oConn,1,1
Do while not lRs.eof
str = str&lRs("tk_id")&","
%>
<tr>
<td><%=lRs("tk_id")%></td>
</tr>
<%
lRs.Movenext
loop
lRs.Close
set lRs=nothing
cRs.Movenext
loop
cRs.Close
set cRs=nothing
str = left(str,int(len(str)-1))
strArr = split(str,",")
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询