asp代码 竖排改为横排,一排4个 5
subShowArticle(TitleLen)ifTitleLen<0orTitleLen>200thenTitleLen=50endififcurrentpage<1...
sub ShowArticle(TitleLen)
if TitleLen<0 or TitleLen>200 then
TitleLen=50
end if
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
sqlArticle="select top " & MaxPerPage
else
sqlArticle="select "
end if
sqlArticle=sqlArticle & " ArticleID,Product_Id,BigClassName,SmallClassName,IncludePic,Title,Price,Spec,Unit,Memo,Key,DefaultPicUrl,UpdateTime,Hits from Product where Passed=True "
if BigClassName<>"" then
sqlArticle=sqlArticle & " and BigClassName='" & BigClassName & "' "
if SmallClassName<>"" then
sqlArticle=sqlArticle & " and SmallClassName='" & SmallClassName & "' "
end if
else
if SpecialName<>"" then
sqlArticle=sqlArticle & " and SpecialName='" & SpecialName & "' "
end if
end if
sqlArticle=sqlArticle & " order by articleid desc"
Set rsArticle= Server.CreateObject("ADODB.Recordset")
rsArticle.open sqlArticle,conn,1,1
if rsArticle.bof and rsArticle.eof then
response.Write("<br><li>没有任何产品</li>")
else
if currentPage=1 then
call ArticleContent(TitleLen)
else
if (currentPage-1)*MaxPerPage<totalPut then
rsArticle.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rsArticle.bookmark
call ArticleContent(TitleLen)
else
currentPage=1
call ArticleContent(TitleLen)
end if
end if
end if
rsArticle.close
set rsArticle=nothing
end sub
sub ArticleContent(intTitleLen)
dim i,strTemp
i=0
do while not rsArticle.eof
strTemp=""
strTemp= strTemp & "<table width=100% border=0 cellspacing=3 cellpadding=0>"
strTemp= strTemp & "<tr>"
strTemp= strTemp & "<td width=25% rowspan=1>"
strTemp= strTemp & "<div align=center><a href=ProductShow.asp?ArticleID=" & rsArticle("articleid") & ">"
fileExt=lcase(getFileExtName(rsArticle("DefaultPicUrl")))
if fileext="jpg" or fileext="bmp" or fileext="png" or fileext="gif" then
strTemp= strTemp & "<img border=0 src=" & rsArticle("DefaultPicUrl") & " width=105 height=100>"
else
if fileext="swf" then
strTemp= strTemp & "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='105' height='100'>"
end if
end if
strTemp= strTemp & "</a></div>"
strTemp= strTemp & "<div align=center><a href=ProductShow.asp?ArticleID=" & rsArticle("articleid") & ">" & rsArticle("Title") & ""
strTemp= strTemp & "</a></div></td>"
strTemp= strTemp & "</tr>"
strTemp= strTemp & "</table>"
response.write strTemp
rsArticle.movenext
i=i+1
if i>=MaxPerPage then exit do
loop
end sub 展开
if TitleLen<0 or TitleLen>200 then
TitleLen=50
end if
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
sqlArticle="select top " & MaxPerPage
else
sqlArticle="select "
end if
sqlArticle=sqlArticle & " ArticleID,Product_Id,BigClassName,SmallClassName,IncludePic,Title,Price,Spec,Unit,Memo,Key,DefaultPicUrl,UpdateTime,Hits from Product where Passed=True "
if BigClassName<>"" then
sqlArticle=sqlArticle & " and BigClassName='" & BigClassName & "' "
if SmallClassName<>"" then
sqlArticle=sqlArticle & " and SmallClassName='" & SmallClassName & "' "
end if
else
if SpecialName<>"" then
sqlArticle=sqlArticle & " and SpecialName='" & SpecialName & "' "
end if
end if
sqlArticle=sqlArticle & " order by articleid desc"
Set rsArticle= Server.CreateObject("ADODB.Recordset")
rsArticle.open sqlArticle,conn,1,1
if rsArticle.bof and rsArticle.eof then
response.Write("<br><li>没有任何产品</li>")
else
if currentPage=1 then
call ArticleContent(TitleLen)
else
if (currentPage-1)*MaxPerPage<totalPut then
rsArticle.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rsArticle.bookmark
call ArticleContent(TitleLen)
else
currentPage=1
call ArticleContent(TitleLen)
end if
end if
end if
rsArticle.close
set rsArticle=nothing
end sub
sub ArticleContent(intTitleLen)
dim i,strTemp
i=0
do while not rsArticle.eof
strTemp=""
strTemp= strTemp & "<table width=100% border=0 cellspacing=3 cellpadding=0>"
strTemp= strTemp & "<tr>"
strTemp= strTemp & "<td width=25% rowspan=1>"
strTemp= strTemp & "<div align=center><a href=ProductShow.asp?ArticleID=" & rsArticle("articleid") & ">"
fileExt=lcase(getFileExtName(rsArticle("DefaultPicUrl")))
if fileext="jpg" or fileext="bmp" or fileext="png" or fileext="gif" then
strTemp= strTemp & "<img border=0 src=" & rsArticle("DefaultPicUrl") & " width=105 height=100>"
else
if fileext="swf" then
strTemp= strTemp & "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='105' height='100'>"
end if
end if
strTemp= strTemp & "</a></div>"
strTemp= strTemp & "<div align=center><a href=ProductShow.asp?ArticleID=" & rsArticle("articleid") & ">" & rsArticle("Title") & ""
strTemp= strTemp & "</a></div></td>"
strTemp= strTemp & "</tr>"
strTemp= strTemp & "</table>"
response.write strTemp
rsArticle.movenext
i=i+1
if i>=MaxPerPage then exit do
loop
end sub 展开
2个回答
展开全部
简单的说吧:
i=0
strTemp= strTemp & "<table width=100% border=0 cellspacing=3 cellpadding=0>"
do while not rsArticle.eof
if i mod 4=0 then
'取余数
strTemp= strTemp & "<tr>"
end if
strTemp= strTemp & "<td>"&rs("xxxxx")&"</td>"
if i mod 4=3 then
strTemp= strTemp & "</tr>"
end if
rs.movenext()
loop
strTemp= strTemp & "</table>"
i=0
strTemp= strTemp & "<table width=100% border=0 cellspacing=3 cellpadding=0>"
do while not rsArticle.eof
if i mod 4=0 then
'取余数
strTemp= strTemp & "<tr>"
end if
strTemp= strTemp & "<td>"&rs("xxxxx")&"</td>"
if i mod 4=3 then
strTemp= strTemp & "</tr>"
end if
rs.movenext()
loop
strTemp= strTemp & "</table>"
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询