图片排列问题,附原代码

hscong 2007-03-07 11:34:12
如下列是库中某一字段。横线表示是图片的路径
_
_
_
_
我想叫它这样排列并能分页,随有一个可行的办法,谢了。
_ _ _ _ _
_ _ _ _ _
_ _ _ _ _

<%
case "small"
anclassid=request("anid")
if not isnumeric(anclassid) then
response.write"<script>alert(""非法访问!"");location.href=""../index.asp"";</script>"
response.end
else
if not isinteger(anclassid) then
response.write"<script>alert(""非法访问!"");location.href=""../index.asp"";</script>"
else
nclassid=request("nid")
if not isnumeric(nclassid) then
response.write"<script>alert(""非法访问!"");location.href=""../index.asp"";</script>"
response.end
else
if not isinteger(nclassid) then
response.write"<script>alert(""非法访问!"");location.href=""../index.asp"";</script>"
else
set rs=server.createobject("adodb.recordset")
rs.open "select * from shop_anclass where anclassid="&anclassid,conn,1,1
anclassname=rs("anclass")
rs.close
rs.open "select * from shop_nclass where nclassid="&nclassid,conn,1,1
nclassname=rs("nclass")
rs.close
%>
<tr>
<td height=61 valign="top"> </td>
</tr>
<%
end if
end if
end if
end if

case "tejia"%>
<%case "hot"%>
<%case "news"%>
<%case else%>
<%end select%>
</table>
<%set rs=server.createobject("adodb.recordset")
if leixing="big" then
rs.open "select * from shop_books where anclassid="&anclassid&" order by adddate desc",conn,1,1
elseif leixing="small" then
rs.open "select * from shop_books where anclassid="&anclassid&" and nclassid="&nclassid&" order by adddate desc",conn,1,1
elseif leixing="hot" then
rs.open "select * from shop_books order by chengjiaocount desc",conn,1,1
elseif leixing="tejia" then
rs.open "select * from shop_books where tejiabook=1 order by adddate desc",conn,1,1
elseif leixing="news" then
rs.open "select * from shop_books where newsbook=1 order by adddate desc",conn,1,1
else
rs.open "select * from shop_books where newsbook=1 order by adddate desc",conn,1,1
end if
if rs.recordcount=0 then
%>
<table width="370" border="0" cellspacing="0" cellpadding="5" align="center">
<tr>
<td align=center>暂无商品</td>
</tr>
</table>
<%
else
rs.PageSize =5 '每页记录条数
iCount=rs.RecordCount '记录总数
iPageSize=rs.PageSize
maxpage=rs.PageCount
page=request("page")

if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if

if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if

rs.AbsolutePage=Page

if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if
For i=1 To x
%>
<table width="96" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><%if rs("bookpic")="" then
response.write "<div align=center><a href=list.asp?id="&rs("bookid")&" ><img src=images/emptybook.gif width=100 height=100 border=0></a></div>"
else%>
<a href="list.asp?id=<%=rs("bookid")%>" ><img src="<%=trim(rs("bookpic"))%>" width="100" border="0" height="100" /></a>
<%end if%></td>
</tr>
</table>
<table width="96" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><%if rs("bookpic")="" then
response.write "<div align=center><a href=list.asp?id="&rs("bookid")&" ><img src=images/emptybook.gif width=100 height=100 border=0></a></div>"
else%>
<a href="list.asp?id=<%=rs("bookid")%>" ><img src="<%=trim(rs("bookpic"))%>" width="100" border="0" height="100" /></a>
<%end if%></td>
</tr>
</table>
...全文
219 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
无爱大叔 2007-03-07
  • 打赏
  • 举报
回复
嗯,上面的没有测试,应该是这样的。
<table>
<tr>
<%
For i=1 to 31
if i mod 5=0 Then '一行5个
response.write("<td>"&i&"</td></tr><tr>")
else
response.write("<td>"&i&"</td>")
end if
'rs.movenext
Next
%>
</tr>
</table>
无爱大叔 2007-03-07
  • 打赏
  • 举报
回复
倒看不懂你的代码哦。
横排显示可以用Mod(取模)来做
如:
<tr>
<%
For i=1 to rs.recordcount
if i mod 5=0 Then '一行5个
response.write("</tr><tr>")
else
response.write("<td>"&rs("bookpic")&"</td>")
end if
rs.movenext
Next
%>
</tr>
hscong 2007-03-07
  • 打赏
  • 举报
回复
加了,不行``````很奇怪。。。。
你能帮我改一下吗?感谢。
无爱大叔 2007-03-07
  • 打赏
  • 举报
回复
把上面的i=1 to 31变成
i=1 to rs.recordcount

response.write("<td>"&i&"....)换成response.write("<td>"&rs("bookpic")&"....)
hscong 2007-03-07
  • 打赏
  • 举报
回复
不知道把这代码插到那里去。能解释下?

28,391

社区成员

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

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