function 函数(s) '判断yxp的排号是否与当序号想对应 set frs=conn.execute("select * from 表 where yxp="&s) if frs.eof then 函数=false else 函数=true end if set frs=nothingend functionsub 过程(s) '输出yxp的数据 set 展开
function 函数(s) '判断yxp的排号是否与当序号想对应 set frs=conn.execute("select * from 表 where yxp="&s) if frs.eof then 函数=false else 函数=true end if set frs=nothingend functionsub 过程(s) '输出yxp的数据 set grs=conn.execute("select * from 表 where yxp="&s) if not grs.eof then '输出此yxp的相应数据 end if set grs=nothingend subfor k = 1 to rs.recordcountif 函数(k) then '调用函数判断此序号是否被排号所占 call 过程(k) '输出此排号的相应数据 rs.moveprevious '指针上移一条,避免遗漏数据else for i=k to rs.recordcount if rs.eof then exit for if not isnumeric(rs("yxp")) then 'yxp字段的数据类型是数字 '如果不是数字 输出自然排序的数据 exit for '退出循环 end if rs.movenext nextend ifrs.movenextnext不知道你要的是不是这效果,测试OK cs字段是用来做对比的,直接复制修改字段名就可测试<!--#include file="conn.asp"--><%function functioncode(s) dim srs set crs=conn.execute("select * from news where pxy="&s) if crs.eof then functioncode=false else functioncode=true end if set crs=nothingend functionsub subcode(s) dim srs set srs=conn.execute("select * from news where pxy="&s) if not srs.eof then response.write "<tr><td>"&s&"</td><td>"&srs("cs")&"</td><td>"&srs("title")&"</td></tr>"end if set srs=nothingend subsql = "select * from news order by xe desc"set rs=server.createobject("adodb.recordset") rs.open sql,conn,1,1 if not rs.bof and not rs.eof thenresponse.write "<table border=1 align=center width=500>"for k = 1 to rs.recordcountif functioncode(k) then call subcode(k) rs.movepreviouselse for i=k to rs.recordcount if rs.eof then exit for if not isnumeric(rs("pxy")) then response.write "<tr><td>"&k&"</td><td>"&rs("cs")&"</td><td>"&rs("title")&"</td></tr>"exit for end if rs.movenext nextend ifrs.movenextnextresponse.write "</table>"end ifrs.closeset rs=nothingcall close_conn%>收起