日期:2014-05-17  浏览次数:20816 次

大家来关注一下这个算法怎么解决
我现在有一个产品表,如下
ID         ProductImg       ProductName
1           imgs/1.jpg         产品一
2           imgs/2.jpg         产品二
3           imgs/3.jpg         产品三

如何才能用下面的形式显示出来

<table>
<tr> <td> <img   src= "imgs/1.jpg "> </td> <td> <img   src= "imgs/2.jpg "> </td> <td> <img   src= "imgs/3.jpg "> </td> </tr>
<tr> <td> 产品一 </td> <td> 产品二 </td> <td> 产品三 </td> </tr>
</table>

------解决方案--------------------
<table width= "95% " height= "235 " border= "0 " align= "center " cellpadding= "0 ">
<tr>
<%
set Rs=server.createobject( "adodb.recordset ")
SQL= "select * from xxxxx order by id desc "
Rs.open SQL,conn,1,1
j=1
%> <%do while not Rs.eof%>
<td width= "608 " height= "206 " align= "left " bgcolor= "#FBF8F3 " class= "style2 ">
<table width= "160 " border= "0 " align= "center " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td width= "160 "> <img src= "image/tu_top.jpg " width= "160 " height= "9 "> </td>
</tr>
<tr>
<td background= "image/tu_bg.jpg "> <table width= "108 " border= "0 " align= "center " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td width= "108 " height= "122 " align= "center "> <%if rs( "img ") <> " " then%>
<a href= "xxxxxxxxx " target= "_blank "> <img src= " <%=rs( "img ")%> " width= "108 " height= "86 " border= "0 "> </a>
<%else%>
<span class= "style13 "> NO PiC </span>
<%end if%> </td>
</tr>
<tr>
<td height= "22 " align= "center " class= "z1 "> <span class= "style10 "> <%=rs( "title ")%> </span> </td>
</tr>
</table> </td>
</tr>
<tr>
<td> <img src= "image/tu_buttom.jpg " width= "160 " height= "9 "> </td>
</tr>
</table> </td>
<%if j mod 5 = 0 then %> '每行5个
</tr>
<tr>
<%end if%>
<%Rs.movenext
j=j+1
loop
Rs.close
set Rs=nothing
%>
</tr>
</table>
------解决方案--------------------
在rs.movenext之前将要在多行显示的字段先用变量暂存一下,等一行完毕时再输出。
示例页面:http://www.riqu.com.cn/wzy/rsinmtr.asp
示例代码如下

sql= "select img,name,price from table1 "
set rs=conn.execute(sql)
if not rs.eof then
response.write "