ASP调出的图片怎么换行成一行4个,然后换行?

<%x=trim(request("x"))y=trim(request("y"))w=trim(request("w"))h=trim(request("h"))n=t... <%
x=trim(request("x"))
y=trim(request("y"))
w=trim(request("w"))
h=trim(request("h"))
n=trim(request("n"))
lm2=trim(request("lm2"))
tj=trim(request("tj"))
if lm2="" then lm2=trim(request("lm"))
if n="" then n=20
n=int(n)
open=trim(request("open"))
font=trim(request("font"))
if (not isNumeric(TJ)) then tj=0
if font="" then font=9
if open="1" then
open="_open"
else
open="_self"
end if
if w="" then w=100
if h="" then h=100
if x="" then x=1
if y="" then y=1
x=int(x)
y=int(y)
xy=x*y
if (not isNumeric(lm2)) then
lm2=0
end if

path=config("path")

sql = "select top "&xy&" * from news where ( pic like '%.jpg%' or pic like '%.JPG%' or pic like '%.gif%' or pic like '%.GIF%' ) and sh=1 "
if lm2<>"0" then sql=sql&" and (lm='"&lm2&"' or lm2='"&lm2&"' or lm3='"&lm2&"') "
if tj="1" then sql=sql&" and tj='推荐' "
sql=sql&" order by ontop desc , updat desc , id desc"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open sql,conn,1,1
%>
document.write("<div align=center>");
document.write("<table border=0 cellpadding=0 cellspacing=0 width=100% id=tableasdaDF1>");
<%
if rs.recordcount<>0 then
for yyyy=1 to y
%>
document.write("<tr>");
<%
if rs.eof then exit for
for xxxx=1 to x

id=rs("id")
title=trim(rs("title"))
pic=rs("pic")
pic=replace(pic,"border=","bo=")
pic=replace(pic,"""","")
Filename=rs("filename")
if filename="" then filename=0
if title="" then title=" "
if n<>0 then
ttt="<BR><font color="&rs("titlecolor")&">"&titleb(title,n)&"</font>"
end if
%>
document.write("<td align=center style='font-size:9pt;line-height:150%'><a href='/view.asp?nid=<%=id%>&lm=<%=lm2%>' target='<%=open%>' title='<%=title%>' ><img hspace=2 vspace=2 border=0 width=<%=w%> height=<%=h%> src='<%=pic%>'style='border: 1px solid #666666; padding: 4px; '><br><font style='font-size:9pt'><%=title%></font></a></td>");
<%
rs.movenext
if rs.eof then exit for
next
%>
document.write("</tr>");
<%
next
else
%>
document.write("暂无图片信息");
<%
end if
%>
document.write("</table>");
document.write("</div>");

<%
conn.close:set conn=nothing
%>
谢谢大家用我上面的代码修改,谢谢……我的QQ:1045566355我把源代码发给你看……谢谢大家的帮帮忙啊。
展开
 我来答
xhcms
推荐于2016-08-26 · 超过63用户采纳过TA的回答
知道答主
回答量:179
采纳率:0%
帮助的人:183万
展开全部
根据上述问题。我理解为:从数据库读取图片。用TABLE布局,然后每行显示4个图片,超过4个时自动换到下一行?对吗?
如果是这样那么我们帮你修正了代码,另源代码实在是太乱了。所以帮你把代码简化并格式化了一下。
修正后代码如下:
<%
Dim RowNums:RowNums = 4'每行显示图片个数,大于0的正整数即可。
Dim Total:Total = 20'总共要显示的图片数,大于0的正整数即可。
Dim X,Y,W,H,N,LM2,TJ
Rem GET变量并进行逻辑判断
x=trim(request("x")):if x="" then x=1
y=trim(request("y")):if y="" then y=1
w=trim(request("w")):if w="" then w=100
h=trim(request("h")):if h="" then h=100
n=trim(request("n")):if n="" then n=20
lm2=trim(request("lm2")):if lm2="" then lm2=trim(request("lm"))
if (not isNumeric(lm2)) then lm2=0
tj=trim(request("tj")):if not isNumeric(TJ) then tj=0
open="_self":if trim(request("open"))<>"" then open="_open"
font=trim(request("font")):if font="" then font=9
x=int(x):y=int(y):xy=x*y:n=int(n)
path=config("path")

Rem 合成SQL。并提取记录
Dim sql,rs,i:i=0
sql = "select top "&xy&" * from news where ( pic like '%.jpg%' or pic like '%.JPG%' or pic like '%.gif%' or pic like '%.GIF%' ) and sh=1 "
if lm2<>"0" then sql=sql&" and (lm='"&lm2&"' or lm2='"&lm2&"' or lm3='"&lm2&"') "
if tj="1" then sql=sql&" and tj='推荐' "
sql=sql&" order by ontop desc , updat desc , id desc"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open sql,conn,1,1
With Response
.Write "document.write('<div align=center><table border=0 cellpadding=0 cellspacing=0 width=100% id=tableasdaDF1>');"
If rs.Eof And rs.Bof Then'如果数据库中没有记录
Rs.Close:Set Rs = Nothing
.Write "document.write('<tr><td>暂无图片信息</td></tr>');"
Else'有需要的记录
.Write "document.write('<tr>');"
Do While Not Rs.EOF
i = i + 1
title=trim(rs("title")):if title="" then title=""
pic=replace(rs("pic"),"border=","bo="):pic=replace(pic,Chr(34),"")
filename=rs("filename"):if filename="" then filename=0
if n<>0 then ttt="<BR><font color="&rs("titlecolor")&">"&titleb(title,n)&"</font>"'ttt是干什么的?怎么没有调用?
.Write "document.write('<td align=center style=""font-size:9pt;line-height:150%""><a "
.Write "href=""/view.asp?nid="&rs("id")&"&lm="&lm2&""" target="""&open&""" title="""&title&""" >"
.Write "<img hspace=2 vspace=2 border=0 width="&W&" height="&H&" src="""&pic&""" "
.Write "style=""border: 1px solid #666666; padding: 4px; ""><br><font style=""font-size:9pt"">"&title&"</font></a></td>');"
If (I Mod RowNums)=0 Then .Write "document.write('</tr><tr>');"
If I >= CLng(Total) Then Exit Do
Rs.movenext
Loop
Rs.Close:Set Rs = Nothing
End If
.Write "document.write('</table></div>');"
End With
conn.close:set conn=nothing

%>
百度网友856c3dd
2010-10-02 · TA获得超过2222个赞
知道大有可为答主
回答量:3168
采纳率:0%
帮助的人:2522万
展开全部
分页代码问题,吧你的嵌套进去

asp模块化分页制作详解

以下正文:

模块化分页

1.查询语句块

<%
取得当前文件名
temp = Split(request.ServerVariables("URL"), "/")
fy = temp(UBound(temp))
set rs=server.createobject("adodb.recordset")
if not isempty(request("page")) then
pagecount=cint(request("page"))
else
pagecount=1
end if
sql="select 查询语句"
rs.open sql,conn,1,1
rs.pagesize=10 分页记录数
if pagecount>rs.pagecount or pagecount<=0 then
pagecount=1
end if
if rs.eof and rs.bof then%>

<div align="center" class="001"><br>
对不起,没有符合搜索条件的记录!<br>
</div>

2.显示记录块

<%
else
rs.AbsolutePage=pagecount
do while not rs.eof %>

显示的记录

<% i=i+2
rs.movenext
if i>=rs.PageSize then exit do
loop
%>

3.
分页效果
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0">
<tr align="center">
<% if rs.pagecount=1 then %>
<td height="35" colspan="4" class=001><font color="#000000">共有[<font color="#ff0000"><%=rs.recordcount%></font>]条信息 当前显示第 <font color="red">1~<%=rs.recordcount%></font>条</font></td>
</tr>
<tr>
<%else%>
<td width="19%" height="35" align="center" valign="middle" class=001><font color="#000000">
<% page_start=(pagecount-1)*rs.pagesize
if pagecount=1 then page_start=1
page_end=rs.pagesize*pagecount
if pagecount*rs.pagesize=>rs.recordcount then page_end=rs.recordcount end if%>
共有[<font color="#ff0000"><%=rs.recordcount%></font>]信息</font></td>
<td width="58%" height="30" align="center" class="fy"><font color="#000000">
<%
if pagecount>5 and pagecount< rs.PageCount-5 and rs.pagecount>10 then
qizu=pagecount-4
min=pagecount+5
response.write"<a href="&source&"?page=1&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&title="&title&"&cityid="&cityid&">
<font color='0000BE'>首页</font></a> "
response.write"<a href="&source&"?page="+cstr(pagecount-1)+"&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&title="&title&"&cityid="&cityid&">
<font color='0000BE'>上一页</font></a> "
for ipage=qizu to min
if ipage<>pagecount then
response.write"<a href="&source&"?page="+cstr(ipage)+"&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&cityid="&cityid&"><font color='0000BE'>"+cstr(ipage)+"</font></a> "
else
response.write "<font color='#FF0000'>"&ipage&"</font> "
end if
next
response.write"<a href="&source&"?page="+cstr(pagecount+1)+"&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&title="&title&"&cityid="&cityid&">
<font color='0000BE'>下一页</font></a> "
response.write"<a href="&source&"?page="+cstr(rs.PageCount)+"&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&title="&title&"&cityid="&cityid&">
<font color='0000BE'>尾页</font></a>"
end if
if rs.PageCount<11 then
for ipage=1 to rs.PageCount
if ipage<>pagecount then
response.write"<a href="&source&"?page="+cstr(ipage)+"&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&cityid="&cityid&"><font color='0000BE'>"+cstr(ipage)+"</font></a> "
else
response.write "<font color='#FF0000'>"&ipage&"</font> "
end if
next
end if
if pagecount < 6 and rs.PageCount>10 then
for ipage=1 to 10
if ipage<>pagecount then
response.write"<a href="&source&"?page="+cstr(ipage)+"&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&cityid="&cityid&"><font color='0000BE'>"+cstr(ipage)+"</font></a> "
else
response.write "<font color='#FF0000'>"&ipage&"</font> "
end if
next
response.write "<a href="&source&"?page="+cstr(rs.PageCount)+"&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&title="&title&"&cityid="&cityid&">
<font color='0000BE'>尾页</font></a>"
end if
if pagecount>rs.PageCount-6 and rs.PageCount>10 then
response.write "<a href="&source&"?page=1&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&title="&title&"&cityid="&cityid&">
<font color='0000BE'>首页</font></a> "
for ipage=rs.PageCount-9 to rs.PageCount
if ipage<>pagecount then
response.write"<a href="&source&"?page="+cstr(ipage)+"&sortid="&sortid&"&typeid="&typeid&"&qylb="&qylb&"&cityid="&cityid&"><font color='0000BE'>"+cstr(ipage)+"</font></a> "
else
response.write "<font color='#FF0000'>"&ipage&"</font> "
end if
next
end if
%>
</font></td><form name=go2to form method=Post action=<%=fy%>>
<td width="13%" align="center" valign="middle" class="fy">
<input type='hidden' name='sortid' value="<%=sortid%>"><input type='hidden' name='typeid' value="<%=typeid%>"><input type='hidden' name='qylb' value="<%=qylb%>"><input type='hidden' name='title' value="<%title%>"><input type='hidden' name='cityid' value="<%=cityid%>"><font color='000064'> 转到第<input type='text' name='page' size=2 maxLength=3>
页</font>
</td>
<td width="10%" align="center" valign="middle" class="fy"><input name="image" type='image' onClick=check() value='确 定' src='../images/button_h.jpg'></td>
</form>
<tr>
<td height="20" colspan="6" valign="bottom"><font color="#000000">  </font></td>
</tr>
<% end if %>
<% end if %>
</table>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2010-10-05
展开全部
这个可以用div实现
<style>
.small{width:100px;float:left}
</style>
<div style="width:400px">
<div class="small">
<div class="small">
<div class="small">
<div class="small">
</div>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
小尾巴的野猫
2010-10-09
知道答主
回答量:11
采纳率:0%
帮助的人:0
展开全部
if yyyy mod 5 =0 then
response.write("<tr>")
end if
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式