首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

初哥,第一次提问,大家关怀一下,该如何解决

2012-02-28 
初哥,第一次提问,大家关怀一下subArticleContent(intTitleLen)dimi,strTempi0dowhilenotrsArticle.eofstr

初哥,第一次提问,大家关怀一下
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> <div   align=center> "
strTemp=   strTemp   &   "   <a   href=ArticleShow.asp?ArticleID= "   &   rsArticle( "articleid ")   &   "> "
strTemp=   strTemp   &   " <img   border=0   src= "   &   rsArticle( "DefaultPicUrl ")   &   "   width=120   > "
strTemp=   strTemp   &   " </a> </div> "
strTemp=   strTemp   &   " </td> "
strTemp=   strTemp   &   " </tr> "    
strTemp=   strTemp   &   " <td> <div   align=center> "
strTemp=   strTemp   &   " <a   href=ArticleShow.asp?ArticleID= "   &   rsArticle( "articleid ")   &   "> "   &   rsArticle( "Title ")   &   " "
strTemp=   strTemp   &   " </a> </div> "
strTemp   =   strTemp   &   " </table> "
response.write   strTemp
rsArticle.movenext
i=i+1
if   i> =MaxPerPage   then   exit   do
loop
end   sub  


调用上面这段代码图片显示是一列多行的
1
2
3
4
我想让他是三列多行的
1 2 3 
4 5 6

不知道要怎么循环

[解决办法]
先理解表格的tr td标签

循环的话,就是根据mod余数是否为3来加tr标签
[解决办法]
sub ArticleContent(intTitleLen)
dim i,strTemp
i=0
response.write " <table> <tr> "
do while not rsArticle.eof
strTemp= " "
strTemp= strTemp & " <table width=100% border=0 cellspacing=3 cellpadding=0> "
strTemp= strTemp & " <tr> "
strTemp= strTemp & " <td> <div align=center> "
strTemp= strTemp & " <a href=ArticleShow.asp?ArticleID= " & rsArticle( "articleid ") & "> "
strTemp= strTemp & " <img border=0 src= " & rsArticle( "DefaultPicUrl ") & " width=120 > "
strTemp= strTemp & " </a> </div> "
strTemp= strTemp & " </td> "
strTemp= strTemp & " </tr> "
strTemp= strTemp & " <td> <div align=center> "
strTemp= strTemp & " <a href=ArticleShow.asp?ArticleID= " & rsArticle( "articleid ") & "> " & rsArticle( "Title ") & " "
strTemp= strTemp & " </a> </div> "
strTemp = strTemp & " </table> "
response.write " <td> " & strTemp & " </td> "
If i Mod 3 = 0 Then response.write " </tr> <tr> "
rsArticle.movenext
i=i+1
if i> =MaxPerPage then exit do
Loop
response.write " </tr> </table> "


end sub
[解决办法]
<table border= "0 " width= "100% " id= "table1 ">
<!--#include file= "Fenye.asp "-->
<%
dim rs,sql,i,page
page=request.QueryString( "page ")
if page= " " or Not IsNumeric(Page) then page=1
sql= "select * from Product where sort_id=23 order by audit asc,dateandtime Desc "
set rs=server.CreateObject( "ADODB.RecordSet ")
rs.Open sql,conn,1,1
rs.PageSize=8
if rs.bof and rs.eof then
%>
<tr>
<td colspan= "3 "> 暂无信息 </td>
</tr>
<%
else
i=0
rs.AbsolutePage=page
while not rs.eof and i <rs.PageSize/2
%>
<tr>
<%for j=1 to 2 '列数%>
<td width= "195 " align= "center ">
<%if not rs.eof then%>
<table border= "0 " width= "100% " id= "table2 ">
<tr>
<td> <a href= "cpshow.asp?id= <%=rs( "shop_id ")%> " target= "_blank ">
<img border= "0 " src= "admin/webedit/UploadFile/ <%=rs( "pic ")%> " width= "184 " height= "137 "> </a> </td>
</tr>
<tr>
<td align= "center " height= "25 "> <a href= "cpshow.asp?id= <%=rs( "shop_id ")%> " target= "_blank "> <%=rs( "name ")%> </a> </td>
</tr>
</table>
<%
rs.MoveNext
end if%>
</td>
<%next%>
</tr>
<%
i=i+1
wend
end if
%>
</table>
[解决办法]
给你一段代码,你自己看一下吧
<%
n = 1
do while not rs.eof
if n mod 3 = 1 then
%>
<tr>
<td> <%=rs( "name ")%> </td>
<%end if%>
<%if n mod 3 =0 then%>
<td> <%=rs( "name ")%> </td> </tr>
<%else%>
<td> <%=rs( "name ")%> </td>
<%end if%>
<%
rs.movenext
n=n+1
loop
%>
[解决办法]
<style>
#demo ul {width:300px;}
#demo ul li {width:100px; float:left;}
</style>
<div id= "demo ">
<ul>
<li> 1 </li>
<li> 2 </li>
<li> 3 </li>
<li> 4 </li>
<li> 5 </li>
<li> 6 </li>
<li> 7 </li>
<li> 8 </li>
<li> 9 </li>
<li> 10 </li>
<li> 11 </li>
<li> 12 </li>
<li> 13 </li>
</ul>
</div>

[解决办法]


sub ArticleContent(intTitleLen)
dim i,strTemp,f
i=0
f = 1
response.write " <table> <tr> "
do while not rsArticle.eof
strTemp= " "
strTemp= strTemp & " <table width=100% border=0 cellspacing=3 cellpadding=0> "
strTemp= strTemp & " <tr> "
strTemp= strTemp & " <td> <div align=center> "
strTemp= strTemp & " <a href=ArticleShow.asp?ArticleID= " & rsArticle( "articleid ") & "> "
strTemp= strTemp & " <img border=0 src= " & rsArticle( "DefaultPicUrl ") & " width=120 > "
strTemp= strTemp & " </a> </div> "
strTemp= strTemp & " </td> "
strTemp= strTemp & " </tr> "
strTemp= strTemp & " <td> <div align=center> "
strTemp= strTemp & " <a href=ArticleShow.asp?ArticleID= " & rsArticle( "articleid ") & "> " & rsArticle( "Title ") & " "
strTemp= strTemp & " </a> </div> "
strTemp = strTemp & " </table> "
response.write " <td> " & strTemp & " </td> "
If f Mod 3 = 0 Then response.write " </tr> <tr> "
rsArticle.movenext
i=i+1
f = f +1
if i> =MaxPerPage then exit do
Loop
response.write " </tr> </table> "
end sub

热点排行