读书人

小弟我需要用asp写一个记录集控制2行2

发布时间: 2012-03-21 13:33:15 作者: rapoo

我需要用asp写一个记录集控制2行2列的表格!分不够可以加,谢谢
<%

dim objRs2,strSql2,id2,flag
flag=false
'id=Request.QueryString( "teacher_id ")
strSql2= "select top 4 * from product where product_class= " "软件产品 " " "
set objRs2=server.CreateObject( "ADODB.recordset ")
objRs2.open strSql2, Conn, 1,1

if (objRs2.bof and objRs2.eof) then
response.Write "产品暂时没有数据 "
else

%>

<table width= "98% " border= "0 " cellspacing= "0 " cellpadding= "0 ">
<tr>
<td align= "center " valign= "top "> <table width= "98% " border= "0 " cellspacing= "0 " cellpadding= "0 ">
<tr> <% do while not objRs2.eof%>
<td width= "45% " align= "center " valign= "top ">
<table width= "100% " border= "0 " cellspacing= "0 " cellpadding= "0 ">
<tr>
<td height= "20 "> <STRONG> <FONT size=2> <%=view(20,objRs2( "product_title "))%> </FONT> </STRONG> </td>
</tr>
<tr>


<td valign= "top "> <table width= "100% " border= "0 " cellspacing= "0 " cellpadding= "0 ">
<tr>
<td width= "26% "> <%if objRs2( "product_pic ") <> " " then%>
<img src= "up_img/ <%=objRs2( "product_pic ")%> ">
<%else %>
无图片
<%end if%> </td>
<td width= "74% " align= "left ">       <%=view(20,objRs2( "product_content "))%> </td>
</tr>
</table> </td>


</tr>
</table>
</td> <%
objRs2.movenext
loop%>
</tr>
</table> </td>
</tr>
<tr>
<td>   </td>
</tr>
</table> <%end if%>

现在是1行4列怎样控制换行!


[解决办法]
<% do while not objRs2.eof%> 改成:

<%
i=0;
do while not objRs2.eof
if i=2 then response.write " </tr> <tr> "
i=i+1
%>

读书人网 >ASP

热点推荐