乔治克鲁尼龙凤胎照片:怎么让产品分行显示?
来源:百度文库 编辑:神马品牌网 时间:2024/04/30 09:51:08
网站是ASP的,我的产品只能分一行显示..
我想让产品分2行显示,我应该怎么做??
谢谢!!
把数据做下循环,也就是平时说的:"显示重复区域".在产品数据循环时,选择循环区域为一个单元格,比如说你一行只想显示5个产品,就当指针读到第五行时"Response.Write"<br>"就可以换行了,下面提供代码参考:
<%Dim Test'声明变量
Set Test=server.CreateObject("adodb.recordset")'创建数据库对象
Test.open "select Top 4 * from ProductData where Picture<>''order by Addtimes desc",conn,1,1'打开数据库连接
If Test.eof and Test.bof Then'如果没有符合的数据
Response.write "<table width=310 border=0 cellspacing=0 cellpadding=0><tr><td><center><br><font color=red size=2>暂无数据!</font></td></tr></table>"
Else'否则
%><table width="280" height="105" border="0" cellpadding="0" cellspacing="0">
<%
Dim Nu,Nucount
Nu=int((Test.recordcount+1)/2)'定义每行显示几个产品
If Nu>2 Then
Nu=2
End If
For Nucount=1 To Nu%>'开始循环
<tr>
<td width="140" align="center" valign="top"><div align="center">
<%If Test.eof Then%>'如果有第一个数据则显示
<%Else%>
</div>
<table width="130" height="105" border="0" align="center" cellpadding="0" cellspacing="0" style="border: 1px solid; border-color: #E4E4E4;">
<tr>
<td width="130" height="85" valign="middle"><div align="center"><a href="ShowProduct.asp?ProductID=<%=Test("ID")%>" target="_blank"><img src="<%=Test("Picture")%>" width="120" height="80" border="0" onMouseOut="toolTip()" onMouseOver="toolTip(' 作 者:<%=Test("ProductAuthor")%><br> 来 源:<%=Test("ProductFrom")%><br> 时 间:<%=Formatdatetime(Test("AddTimes"),1)%><br> 点 击:<%=Test("BrowseTimes")%>')"></a>
</div></td>
</tr>
<tr>
<td valign="middle" height="20" style="border-top: 1px solid; border-color: #E4E4E4;"><div align="center"><a href="ShowProduct.asp?ProductID=<%=Test("ID")%>" target="_blank" onMouseOut="toolTip()" onMouseOver="toolTip(' 作 者:<%=Test("ProductAuthor")%><br> 来 源:<%=Test("ProductFrom")%><br> 时 间:<%=Formatdatetime(Test("AddTimes"),1)%><br> 点 击:<%=Test("BrowseTimes")%>')">
<% If Len(trim(Test("ProductTitle")))>7 Then
Response.Write left(trim(Test("ProductTitle")),6)&"..."
Else %>
<%=Test("ProductTitle")%>
<% End if %></a></div></td>
</tr>
<%Test.Movenext%>
</table>
<div align="center">
<%End If%>
</div></td>
<td width="120" align="center" valign="top"><div align="center">
<%If Test.eof Then%>
<%Else%>
</div>
<table width="130" height="105" border="0" align="center" cellpadding="0" cellspacing="0" style="border: 1px solid; border-color: #E4E4E4;">
<tr>
<td width="130" height="85" valign="middle"><div align="center"><a href="ShowProduct.asp?ProductID=<%=Test("ID")%>" target="_blank"><img src="<%=Test("Picture")%>" width="120" height="80" border="0" onMouseOut="toolTip()" onMouseOver="toolTip(' 作 者:<%=Test("ProductAuthor")%><br> 来 源:<%=Test("ProductFrom")%><br> 时 间:<%=Formatdatetime(Test("AddTimes"),1)%><br> 点 击:<%=Test("BrowseTimes")%>')"></a></div>
</td>
</tr>
<tr>
<td valign="middle" height="20" style="border-top: 1px solid; border-color: #E4E4E4;"><div align="center"><a href="ShowProduct.asp?ProductID=<%=Test("ID")%>" target="_blank" onMouseOut="toolTip()" onMouseOver="toolTip(' 作 者:<%=Test("ProductAuthor")%><br> 来 源:<%=Test("ProductFrom")%><br> 时 间:<%=Formatdatetime(Test("AddTimes"),1)%><br> 点 击:<%=Test("BrowseTimes")%>')">
<% If Len(trim(Test("ProductTitle")))>7 Then
Response.Write left(trim(Test("ProductTitle")),6)&"..."
Else %>
<%=Test("ProductTitle")%>
<% End if %></a></div></td>
</tr>
<%Test.Movenext%>
</table>
<div align="center">
<%End if%>
</div></td>
</tr>
<%Next%>
<%Test.Close
Set Test=Nothing%>
</table>
<%End if%>
如果还是解决不了,就加QQ:32936721或访问我们的网站http://suonet.cn