急求换行显示问题解决方法
MaxPerPage=10
代码:
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,DefaultPicUrl,UpdateTime,Hits from Products 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%> "
strTemp= strTemp & " <div align=center> <a href=ProductShow.asp?ArticleID= " & rsArticle( "articleid ") & "> "
fileExt=lcase(getFileExtName(rsArticle( "DefaultPicUrl ")))
strTemp= strTemp & " <img border=0 src=UploadFiles/ " & rsArticle( "DefaultPicUrl ") & " width=105 height=80> "
strTemp= strTemp & " </a> </div> </td> "
strTemp= strTemp & " </tr> <tr> "
strTemp= strTemp & " <td width=12% height=12> "
strTemp= strTemp & "产品名称: "
strTemp= strTemp & " <a href=ProductShow.asp?ArticleID= " & rsArticle( "articleid ") & "> " & rsArticle( "Title ") & " "
strTemp= strTemp & " </a> </td> </tr> "
strTemp= strTemp & " </table> "
response.write strTemp
rsArticle.movenext
i=i+1
if i> =MaxPerPage then exit do
loop
end sub
页面调用
<TR>
<td colspan= "2 "> <% call ShowArticle(32) %> </td>
</TR>
现在显示比如一页显示10个 则是按:
图片
介绍
-----
图片
介绍
-----
图片
介绍
-----
.....
这样的形式显示的
现在想改成:
图片 图片 图片 图片 图片
介绍 介绍 介绍 介绍 介绍
图片 图片 图片 图片 图片
介绍 介绍 介绍 介绍 介绍
这样的形式 一行5个来显示
-----
换了好多方法不行 麻烦GGMM帮忙下 客户等着要 着急上火的了
[解决办法]
用rsArticle.movenext
输出第一个,然后rsArticle.movenext,判断是否到最后一条数据,如果不是,输出第二个,然后再rsArticle.movenext再判断,依此类推,够5条数据就换行,不够就不换
或者用
dim i
i=0
if (i mod 5)=0 then '如果输出了5条数据
换行
else
不换行
end if
然后在相应的地方再加上判断是否已经是最后一条数据即可
[解决办法]
给个基本思路,具体自己去改
<table width= "100% " border= "1 ">
<tr>
<% do while not rsArticle.eof %>
<td>
<table width= "100% " border= "1 ">
<tr>
<td> 图片显示代码 </td>
</tr>
<tr>
<td> 介绍显示代码 </td>
</tr>
</table>
</td>
<%
i=i+1
if if=5 then
response.write " </tr> <tr> "
i=0
end if
rsArticle.movenext
loop %>
</tr>
</table>