超级玛丽安卓制作资源:ASP输出行列问题

来源:百度文库 编辑:神马品牌网 时间:2024/05/04 17:54:48
大家看看我这个程序为什么不对啊?我是想输出2行3列.但就是不行啊,我对这个问题不太懂啊.麻烦各位朋友帮助一下啊?
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<%
set rs_news=server.createobject("adodb.recordset")
sqltext4="select top 3 * from product order by ArticleID desc"
rs_news.open sqltext4,conn,1,1
%><%i=0
do while not rs_news.eof%>

<td width="90" height="90" valign="top" background="images/kuang.gif">
<table width="100%" height="90" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="85" height="73">
<table width="81" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="67"><a href="ArticleShow.asp?ArticleID=<%=rs_news("ArticleID")%

>"><img src="<%=rs_news("DefaultPicUrl")%>" width=81 height=67 border=0 alt='<%=rs_news("title")%>'></a></td>
</tr>
</table></td>
<td width="5"> </td>
</tr>
<tr>
<td colspan="2"><div align=center><a href="ArticleShow.asp?ArticleID=<%=rs_news

("ArticleID")%>"><font color=000000><%=cutstr(rs_news("title"),9)%></font></a></div></td>
</tr>
</table></td><td width="10"> </td>
<%rs_news.movenext
i=i+1
if i=3 then exit do
loop
rs_news.close %>
</tr>
</table>
唉,看不懂啊,能不能再给我说细点啊,我来换了运行不出来啊?有没有人愿意为我改好发在上面啊.

楼上的兄台,你这种做法我曾经就这么写过呵呵真是同道中人,不谋而合啊
不过很可惜的是我要告诉你一下,你这个程序是有漏洞的呵呵
哈哈
我给你说漏洞在那里啊
你和我当初一样,没有考虑到一种情况,就是当数据正好结束而程序正好可以被n整除时,就会出错哈哈,你会很惊喜的发现,你的源代码中会多一对<tr></tr>哈哈这将时最下面的一行单元格好象变高了呵呵
可以这样搞定!
if i mod n=0 and i<> rs.recordcount then
response.write "</tr><tr>"
end if
如果它正好结束呢就会直接写出最后面loop后面的的那个response.write "</tr>"
这样就完美了呵呵朋友,学无止境啊!

if i=3 then exit do;既然exit了当然不再输出第二行了。输出多行多列,假设是一行有n列,那么可以这样:
response.write("<tr>")
i=0
do while not rs.eof'循环开始显示列
response.write("<td>")
response.write("你的内容")
response.write("</td>")
i=i+1
if i mod n=0 then
response.write("</tr><tr>")'显示了n列后换行
end if
rs.movenext
loop
response.write("</tr>")