急!!怎么样实现二行四列显示

fly_013 2009-08-13 08:49:45
大家好,我现在这个程序只能实现一行一列显示我想在这个页面显示八个图片,分别是二行四列来,即分两行,一行四张图,我想加一个判断语句,但是怎么加都不对,麻烦高手指点一下,跪谢!
大概的代码如下:
<table width=100% border=0 cellspacing=2 cellpadding=0>"
strTemp= strTemp & "<tr>"
strTemp= strTemp & "<td width=65% rowspan=4 >"
strTemp= strTemp & "<div align=center ><a href=Productshow.asp?ID=" & rsProduct("ID") & " target=_blank>"

fileExt=lcase(getFileExtName(rsProduct("DefaultPicUrl")))
if fileext="jpg" or fileext="bmp" or fileext="png" or fileext="gif" then
strTemp= strTemp & "<img style='BORDER-LEFT-COLOR: #cccccc; BORDER-BOTTOM-COLOR: #cccccc; BORDER-TOP-COLOR: #cccccc; BORDER-RIGHT-COLOR: #cccccc' src=" & rsProduct("DefaultPicUrl") & " width=80 height=80 onload='javascript:DrawImage(this);'>"
else
if fileext="swf" then
strTemp= strTemp & "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='84' height='84'>"
strTemp= strTemp &"<param name=movie value='"&rsProduct("DefaultPicUrl")&"'>"
strTemp= strTemp &"<param name=quality value=high>"
strTemp= strTemp &"<param name='Play' value='-1'>"
strTemp= strTemp &"<param name='Loop' value='0'>"
strTemp= strTemp &"<param name='Menu' value='-1'>"
strTemp= strTemp &"<embed src='"&rsProduct("DefaultPicUrl")&"' width='84' height='84' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash'></embed> </object>"
end if
end if
strTemp= strTemp & "</td>"

strTemp= strTemp & "</tr>"
strTemp= strTemp & "</table>"
...全文
238 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
lichong876140 2009-08-18
  • 打赏
  • 举报
回复
双循环
fly_013 2009-08-14
  • 打赏
  • 举报
回复
谢谢楼上,我试一下
mailbao 2009-08-14
  • 打赏
  • 举报
回复
從完整的代碼來看,樓主用的是一套程序模版

所以要實現想的功能要在原來的模版上修改一下

即按3樓所說的方法去改,關鍵代碼是這三句
do while not rs.eof
i=i+1
if i mod 4 = 0 then

你只要找到對應的<tr><td>和</td></tr>作為模版的切割點,再進行修改調整即可!
fly_013 2009-08-14
  • 打赏
  • 举报
回复
非常感谢各位的热心回复,谢谢!
有个自定义的函数来定义的
如果用DIV+CSS,调内容的时候调不出来。或是只调了一条内容
'=================================================
'过程名:ShowProduct
'=================================================
sub ShowProduct(TitleLen)
if TitleLen<0 or TitleLen>200 then
TitleLen=50
end if
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
sqlProduct="select top " & MaxPerPage
else
sqlProduct="select "
end if

sqlProduct=sqlProduct & " ID,Product_Id,BigClassName,SmallClassName,IncludePic,Title,Price,Spec,Unit,Memo,DefaultPicUrl,UpdateTime,Hits from Product where Passed=True "

if BigClassName<>"" then
sqlProduct=sqlProduct & " and BigClassName='" & BigClassName & "' "
if SmallClassName<>"" then
sqlProduct=sqlProduct & " and SmallClassName='" & SmallClassName & "' "
end if
end if
sqlProduct=sqlProduct & " order by UpdateTime desc"
Set rsProduct= Server.CreateObject("ADODB.Recordset")
rsProduct.open sqlProduct,conn,1,1
if rsProduct.bof and rsProduct.eof then
response.Write("<br><li>没有任何作品</li>")
else
if currentPage=1 then
call ProductContent(TitleLen)
else
if (currentPage-1)*MaxPerPage<totalPut then
rsProduct.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rsProduct.bookmark
call ProductContent(TitleLen)
else
currentPage=1
call ProductContent(TitleLen)
end if
end if
end if
rsProduct.close
set rsProduct=nothing
end sub

sub ProductContent(intTitleLen)
dim i,strTemp
i=0
do while not rsProduct.eof
strTemp=""
strTemp= strTemp & "<table width=100% border=0 cellspacing=2 cellpadding=0>"
strTemp= strTemp & "<tr>"
strTemp= strTemp & "<td width=65% rowspan=4 >"
strTemp= strTemp & "<div align=center ><a href=Productshow.asp?ID=" & rsProduct("ID") & " target=_blank>"

fileExt=lcase(getFileExtName(rsProduct("DefaultPicUrl")))
if fileext="jpg" or fileext="bmp" or fileext="png" or fileext="gif" then
strTemp= strTemp & "<img style='BORDER-LEFT-COLOR: #cccccc; BORDER-BOTTOM-COLOR: #cccccc; BORDER-TOP-COLOR: #cccccc; BORDER-RIGHT-COLOR: #cccccc' src=" & rsProduct("DefaultPicUrl") & " width=80 height=80 onload='javascript:DrawImage(this);'>"
else
if fileext="swf" then
strTemp= strTemp & "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='84' height='84'>"
strTemp= strTemp &"<param name=movie value='"&rsProduct("DefaultPicUrl")&"'>"
strTemp= strTemp &"<param name=quality value=high>"
strTemp= strTemp &"<param name='Play' value='-1'>"
strTemp= strTemp &"<param name='Loop' value='0'>"
strTemp= strTemp &"<param name='Menu' value='-1'>"
strTemp= strTemp &"<embed src='"&rsProduct("DefaultPicUrl")&"' width='84' height='84' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash'></embed> </object>"
end if
end if


'strTemp= strTemp & "</a></div></td>"
' strTemp= strTemp & "<td width=30% height=10 >"
'strTemp= strTemp & "作品名称:</td>"
'strTemp= strTemp & "<td>"
' strTemp= strTemp & "<a href=Productshow.asp?ID=" & rsProduct("ID") & ">" & rsProduct("Title") & ""
'strTemp= strTemp & "</a></td>"

'strTemp= strTemp & "</tr><tr>"
'strTemp= strTemp & "<td width=20% height=12>"
'strTemp= strTemp & "作品售价:</td>"
'strTemp= strTemp & "<td>" & rsProduct("Price") & "元</td>"

'strTemp= strTemp & "</tr><tr>"
'strTemp= strTemp & "<td width=20% height=12>"
'strTemp= strTemp & "作品规格:</td>"
'strTemp= strTemp & "<td>"
'strTemp= strTemp & rsProduct("Spec") & ""
'strTemp= strTemp & "</a></td>"

'strTemp= strTemp & "</tr><tr>"
'strTemp= strTemp & "<td width=30% height=12 >"
'strTemp= strTemp & "作品备注:</td>"
'strTemp= strTemp & "<td>"
'strTemp= strTemp & rsProduct("Memo") & ""
'strTemp= strTemp & "</a></td>"

'strTemp= strTemp & "</tr><tr>"
' strTemp= strTemp & "<td width=30% height=10>"
'strTemp= strTemp & "作品类别:</td>"
'strTemp= strTemp & "<td><a href=Product.asp?BigClassName="& rsProduct("BigClassName")&">"&rsProduct("BigClassName")&"</a> → "
'strTemp= strTemp & "<a href=Product.asp?BigClassName=" & rsProduct("BigClassName") & "&SmallClassName=" & rsProduct("SmallClassName") & ">" & rsProduct("SmallClassName") & ""
' strTemp= strTemp & "</a></td>"
' strTemp= strTemp & "</tr><tr>"


'strTemp= strTemp & "<td height=12>作品介绍:</td>"
' strTemp= strTemp & "<td>"
'strTemp= strTemp & "<a href=Productshow.asp?ID=" & rsProduct("ID") & " target=_blank><img src=Img/arrow_7.gif border=0></a></td>"
'strTemp= strTemp & "</tr><tr>"
' strTemp= strTemp & "<td colspan=0>"
'strTemp= strTemp & "<table width=50% border=0 cellpadding=0 cellspacing=0>"
'strTemp= strTemp & "<tr>"
'strTemp= strTemp & "<td width=10% height=1>"
'strTemp= strTemp & "<div align=center></div></td>"

'strTemp= strTemp & "<td width=50% height=12>"
'strTemp= strTemp & "<div align=center><input name='Product_Id' type='checkbox' id='Product_Id' value="&cstr(rsProduct("Product_Id"))&"> 选取"
'strTemp= strTemp & "</div></td>"

'strTemp= strTemp & "</tr>"
'strTemp= strTemp & "</table>"
strTemp= strTemp & "</td>"

strTemp= strTemp & "</tr>"
'strTemp= strTemp & "<td height=1 bgcolor=#CCCCCC></td>"
'strTemp= strTemp & "</tr>"
strTemp= strTemp & "</table>"

response.write strTemp
rsProduct.movenext
i=i+1
if i>=MaxPerPage then exit do
loop
end sub
这是程序,现在我只想显示产品的图片,三行四列或是二行三列,现在的显示是只有一列,不会分多列
怕吐 2009-08-14
  • 打赏
  • 举报
回复
也不知道是否看懂了你的意思,为什么不用div+css来实现呢?
<html> 
<head>
<meta http-equiv='Content-Type' content="text/html; charset=gb2312">
<title>test</title>
<style type="text/css">
<!--
a:link {
text-decoration: none;
color: #003399;
}
a:visited {
text-decoration: none;
color: #0066CC;
}
a:hover {
text-decoration: none;
color: #990033;
}
a:active {
text-decoration: none;
color: #0066CC;
}
body {
margin-top: 0px;
background-color: #FFFFFF;
}
.ImgList {
width: 620px;
}

.NewsContent li {
height:140px;
width: 149px;
width: 144px !important;
float: left;
list-style-type: none;
border: 1px solid #CCCCCC;
margin-left: 3px;
text-align: center;
margin-top: 3px;
padding-top: 5px;
padding-right: 0;
padding-bottom: 0;
overflow: hidden;
}
.NewsContent li img{
display:block;
margin:0 auto;
}

-->
</style>
</head>

<body>
<div id="Box">
<div id="contain">
<div id="mainbg">
<div id="right">
<div class="ImgList"><div class="NewsContent"><!--PicCenter:start-->
<li><a href="#" target="_blank"><img border="0" src="http://www.google.cn/logos/orsted09ig.gif"width="130" height="100"><br>
1</a></li>
<li><a href="#" target="_blank"><img border="0" src="http://www.google.cn/logos/orsted09ig.gif"width="130" height="100"><br>
2
</a></li>
<li><a href="#" target="_blank"><img border="0" src="http://www.google.cn/logos/orsted09ig.gif"width="130" height="100"><br>
3
</a></li>
<li><a href="#" target="_blank"><img border="0" src="http://www.google.cn/logos/orsted09ig.gif"width="130" height="100"><br>
4
</a></li>
<li><a href="#" target="_blank"><img border="0" src="http://www.google.cn/logos/orsted09ig.gif"width="130" height="100"><br>
5
</a></li>
<li><a href="#" target="_blank"><img border="0" src="http://www.google.cn/logos/orsted09ig.gif"width="130" height="100"><br>
6
</a></li>
<li><a href="#" target="_blank"><img border="0" src="http://www.google.cn/logos/orsted09ig.gif"width="130" height="100"><br>
7
</a></li>

<!--PicCenter:end--></div></div>




</div>


</div>
</body>
</html>
cnljc 2009-08-14
  • 打赏
  • 举报
回复
没具体看你的,但你可以参考下面的代码--多行4列.如改2行4列,在sql中加top 8

<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<% sql="select * from news order by newsid desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
do while not rs.eof
%>
<td width="25%">
<div align="center">
<a href="info.asp?newsid=<%=rs("newsid")%>" target="_blank"> <img src='<%=rs("photo")%>' width="180" height="116" border="0" /></a><br />
<a href="info.asp?newsid=<%=rs("newsid")%>" target="_blank"><strong><font color="#996600" style="font-size:14px "><%=rs("title")%></font></strong></a><br><br><br>
</div>

</td>
<% i=i+1
if i mod 4 = 0 then
Response.Write "</td></tr>"
end if

rs.movenext
loop
%>
</tr>
</table>
fly_013 2009-08-14
  • 打赏
  • 举报
回复
谢谢rivertrue,我正在调试
rivertrue 2009-08-14
  • 打赏
  • 举报
回复
调用八条数据



<div style="float:left; width:1000px; height:200px; background:#ccc;">
<!-- 这里开始循环调用8条数据 -->
<div style="width:25%; float:left; height:100px; background:#f00;">
调用的内容
</div>
<!-- 这里循环调用结束 -->
</div>



css属性再具体调整一下就好了
fly_013 2009-08-14
  • 打赏
  • 举报
回复
问题是我这个就一个模版了,不知用ul-li+css怎么样实现,重要的是我还是菜鸟,对程序不大懂,嘻嘻,所以请高手指点
谢谢mailbao,我试过了,不行,不知是不是否弄错了, 只显示分页的信息,显示不了内容。
KK3K2005 2009-08-14
  • 打赏
  • 举报
回复
几行几列的 可以用ul-li+css来实现
到时候更改列的数量也方便
lijun_xiao2009 2009-08-13
  • 打赏
  • 举报
回复
你把你的搞好一点吧!要不把整个页面的代码发个来
fly_013 2009-08-13
  • 打赏
  • 举报
回复
可怜啊,怎么没人理我啊?

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧