分類  >  WEB開發>ASP >

怎麼將記錄按8*11的方格顯示,這個循環不太好寫

tags:    時間:2013-12-13 01:09:40
如何將記錄按8*11的方格顯示,這個循環不太好寫
通過select查詢后,如何利用循環將所得數據按一個類似於8*11的方格顯示(一共86條記錄)

這個循環不太好寫

------解決方案--------------------
i=1
do until rs.eof
response.write rs( "aaa ")
if i mod 8=0 then response.write " <br/> "
i=i+1
loop
------解決方案--------------------
就是一共顯示成8列是吧?
i = 1
do while not rs.eof
response.write(rs( "aaa "))
if i % 8 = 0 then
response.write( " <br /> ")
else
response.write( "&nbsp; ")
end if
i = i + 1
rs.movenext
loop
------解決方案--------------------
call GetIndexTop( "Select Top 88 * From Table ") '8*11=88

sub GetIndexTop(SQL)
response.write " <table width= '100% ' border=0 align=center cellpadding=0 cellspacing=0> "
dim i,k
Set Rs=Server.CreateObject( "ADODB.Recordset ")
Rs.open sql,conn,1,1
if rs.eof then
response.write " <tr> <td conspan=8 align=center> 無記錄 </td> </tr> "
else
i=0
do while not rs.eof
i=i+1
if i = 1 or ((i mod 8 = 1) and i > 8 ) Then Response.write " <tr align= 'center '> "&vbCrLf
response.write " <td align=center> "
response.write Rs(0)
response.write " </td> "
if i = 8 or (i mod 8 = 0) Then Response.write " </tr> "&vbCrLf
rs.movenext
loop
If (i mod 4) <> 0 Then
for k = 1 to (8 - (i mod 8))
Response.write " <td align=center> &nbsp; </td> "&vbCrLf
Next
Response.Write " </tr> "&vbCrLf
End If
end if
Rs.Close
Set Rs=Nothing
response.write " </table> "
end sub

推薦閱讀文章

Bookmark the permalink ,來源:互聯網