asp循環(huán)行數(shù)輸出函數(shù)
更新時間:2008年07月25日 23:54:43 作者:
一直以來都很頭疼Asp里面的多行或者多列循環(huán)
今天算是有收獲了以下代碼貼出來為自己留念一下
經(jīng)過大鳥哥的指導已做全面的修改,本人能力有限只能做到下面這步了:
ASP/Visual Basic代碼
<%
Const p=6 '每頁2條
set rs = server.createobject("adodb.recordset")
sql = "Select * from show order by id Desc"
rs.Open sql,conn,1
i=0
do while not rs.eof
%> <td align="center" height="98">
<a href="show.asp?id=<%=rs("id")%>">
<img src="<%=rs("pic")%>" width="150" height="98" alt="<%=rs("name")%>" /></a>
</td>
<%
If (i+1) Mod 3 =0 Then
Response.Write "</tr>"
If i<(p-1) Then Response.Write "<tr>"
End If
i=i+1
if i>p then exit do
rs.movenext
Loop
If i Mod 3 <>0 Then
For m=3-(i Mod 3) To 1 Step -1
response.write"<td> </td>"
Next
response.write"</tr>"
End If
If i = 3 Then
response.write" <td> </td><td> </td><td> </td></tr>"
End if
rs.close
set rs=nothing
%>
之前的代碼未更改
<%
Const p=6 '每頁2條
set rs = server.createobject("adodb.recordset")
sql = "Select * from show order by id Desc"
rs.Open sql,conn,1
i=1
do while not rs.eof
%> <td align="center" height="98">
<a href="show.asp?id=<%=rs("id")%>">
<img src="<%=rs("pic")%>" width="150" height="98" alt="<%=rs("name")%>" /></a>
</td>
<%
if i mod 3 = 0 then
Response.Write("</tr><tr>")
end if
i=i+1
if i>p then exit do
rs.movenext
Loop
rs.close
set rs=nothing
%>
ASP/Visual Basic代碼
復制代碼 代碼如下:
<%
Const p=6 '每頁2條
set rs = server.createobject("adodb.recordset")
sql = "Select * from show order by id Desc"
rs.Open sql,conn,1
i=0
do while not rs.eof
%> <td align="center" height="98">
<a href="show.asp?id=<%=rs("id")%>">
<img src="<%=rs("pic")%>" width="150" height="98" alt="<%=rs("name")%>" /></a>
</td>
<%
If (i+1) Mod 3 =0 Then
Response.Write "</tr>"
If i<(p-1) Then Response.Write "<tr>"
End If
i=i+1
if i>p then exit do
rs.movenext
Loop
If i Mod 3 <>0 Then
For m=3-(i Mod 3) To 1 Step -1
response.write"<td> </td>"
Next
response.write"</tr>"
End If
If i = 3 Then
response.write" <td> </td><td> </td><td> </td></tr>"
End if
rs.close
set rs=nothing
%>
之前的代碼未更改
復制代碼 代碼如下:
<%
Const p=6 '每頁2條
set rs = server.createobject("adodb.recordset")
sql = "Select * from show order by id Desc"
rs.Open sql,conn,1
i=1
do while not rs.eof
%> <td align="center" height="98">
<a href="show.asp?id=<%=rs("id")%>">
<img src="<%=rs("pic")%>" width="150" height="98" alt="<%=rs("name")%>" /></a>
</td>
<%
if i mod 3 = 0 then
Response.Write("</tr><tr>")
end if
i=i+1
if i>p then exit do
rs.movenext
Loop
rs.close
set rs=nothing
%>
相關(guān)文章
ASP基礎(chǔ)入門第十篇(ASP內(nèi)建對象Server)
這篇文章主要介紹了ASP內(nèi)建對象Server的相關(guān)資料,需要的朋友可以參考下2015-10-10
asp(vbscript)中自定義函數(shù)的默認參數(shù)實現(xiàn)代碼
這篇文章主要介紹了asp(vbscript)中自定義函數(shù)的默認參數(shù)實現(xiàn)代碼,需要的朋友可以參考下2020-09-09
微信公眾號可通過現(xiàn)金紅包接口發(fā)放微信支付現(xiàn)金紅包(附開發(fā)教程)
這篇文章主要介紹了微信公眾號可通過現(xiàn)金紅包接口發(fā)放微信支付現(xiàn)金紅包的相關(guān)資料,需要的朋友可以參考下2016-09-09
asp中command的在單條記錄時,有些字段顯示為空的問題
網(wǎng)上找到一些資料,關(guān)于游標這個問題,還是無法放進去(如果方法找到的話,還可以改) 之前的sql這么寫,但是沒有效果有些非順序的值會丟失2008-07-07
使用innerHTML時注意處理空格和回車符(asp后臺處理)
innerHTML中如果包含空格和回車都會被認為是段落的結(jié)束,造成程序運行出錯,解決辦法,輸出的時候?qū)⒖崭窈突剀囂鎿Q掉,方便js調(diào)用。2011-08-08

