求助图片横向排列asp代码
我现在的图片都是向下排的,而且只能显示最新的两个,我的页宽是982,希望一行可以显示5-6张图片,只要一行就可以了。我现在的代码是:<%'开始分页ConstMaxPerP...
我现在的图片都是向下排的,而且只能显示最新的两个,我的页宽是982,希望一行可以显示5-6张图片,只要一行就可以了。
我现在的代码是:
<%'开始分页
Const MaxPerPage=10
dim totalPut
dim CurrentPage
dim TotalPages
if Not isempty(request("page")) then
if request("page")="" then
currentPage=1
else
currentPage=Cint(request("page"))
end if
else
currentPage=1
end if
set rs=server.CreateObject("adodb.recordset")
rs.open "select id,id1,id2,biaoti,neirong,tupian,adddate,name,pic,address from shenheyi order by adddate desc",conn,1,1
if err.number<>0 then
response.write "<div align=center>暂无资料!</center>"
else
if rs.eof And rs.bof then
response.write "<div align=center>暂无资料!</center>"
else
totalPut=rs.recordcount
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
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
else
currentPage=1
end if
end if
i=0
do while not rs.eof
%>
<table width="962" border="0" align="center">
<tr>
<td width="170" valign="top"><a href="read.asp?id=<%=rs("id")%>"><img src="<%=rs("tupian")%>" width='170' border='0'></a></td>
</tr>
<tr>
<td><strong><%=rs("biaoti")%></strong></td>
</tr>
</table>
<%
if not rs.eof then rs.movenext
if rs.eof then
response.write "<td width='381'></td></tr>"
else
%>
<%
end if
i=i+1
if i>=5 then Exit Do
if not rs.eof then rs.movenext
loop
end if
end if
rs.close
set rs=nothing
%>
跪求各位大侠帮帮我啊!!!!
最好能标出更改的地方和作用。。。我想看懂更改的原因。。。谢谢啦!!努力学习ing。。。。 展开
我现在的代码是:
<%'开始分页
Const MaxPerPage=10
dim totalPut
dim CurrentPage
dim TotalPages
if Not isempty(request("page")) then
if request("page")="" then
currentPage=1
else
currentPage=Cint(request("page"))
end if
else
currentPage=1
end if
set rs=server.CreateObject("adodb.recordset")
rs.open "select id,id1,id2,biaoti,neirong,tupian,adddate,name,pic,address from shenheyi order by adddate desc",conn,1,1
if err.number<>0 then
response.write "<div align=center>暂无资料!</center>"
else
if rs.eof And rs.bof then
response.write "<div align=center>暂无资料!</center>"
else
totalPut=rs.recordcount
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
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
else
currentPage=1
end if
end if
i=0
do while not rs.eof
%>
<table width="962" border="0" align="center">
<tr>
<td width="170" valign="top"><a href="read.asp?id=<%=rs("id")%>"><img src="<%=rs("tupian")%>" width='170' border='0'></a></td>
</tr>
<tr>
<td><strong><%=rs("biaoti")%></strong></td>
</tr>
</table>
<%
if not rs.eof then rs.movenext
if rs.eof then
response.write "<td width='381'></td></tr>"
else
%>
<%
end if
i=i+1
if i>=5 then Exit Do
if not rs.eof then rs.movenext
loop
end if
end if
rs.close
set rs=nothing
%>
跪求各位大侠帮帮我啊!!!!
最好能标出更改的地方和作用。。。我想看懂更改的原因。。。谢谢啦!!努力学习ing。。。。 展开
4个回答
展开全部
1.我的图片是一行4张,每页显示20第,也就是排5行,如果你只要每页一行,就把"pagesize=20"改成"pagesize=4"就行了.
2.中间的代码是与我的数据库相连的,你改成与你的数据库相关参数就行了
3.代码贴如下:
<%
Dim totalPages,currentPage
Dim rs,sql
Dim PageSize
Set rs=server.createobject("adodb.recordset")
sql="select picID,filename,name,title,width,height,visitcount,classid,uptime,typeid from Photo order by visitcount desc"
rs.open sql,conn,1,1
response.write "<table border=0 width=""100%"" Class=DarkTableBody align=center >"
pagesize=20
rs.pagesize=pagesize
totalpages=rs.pagecount
currentPage=Request("page")
if currentpage="" Then currentpage=1
if not isNumeric(currentpage) Then
currentpage=1
ElseIf Cint(currentpage)>totalpages Then
currentpage=totalpages
End if
currentpage=Cint(currentpage)
rs.absolutepage=currentpage
for i=1 to pagesize
If rs.eof Then
if i mod 4=0 then'---每行显示的图片数量
response.write "<tr Class=LightTableBody >"
end if
EXIT FOR
End If
response.write "<td align=center height=""100%"">"&_
"<table width=""180"" height=""100%"" border=0 align=center>"&_
"<tr>"&_
"<td height=120 align=center ><table border=0 cellspacing=0 cellpadding=0 width=""100%"" height=""100%"" align=center ><tr><td align=center><A href=ClassAlbum.asp?CLassID="&rs("classid")&"&Action=ShowPhoto&PhotoID="&rs("picID")&" target=_blank ><img src="&StrVar(8)&rs(1)&" "&sizeadjust(rs(4),rs(5),110)&" border=0 ></a></td></tr></table></td></tr>"
response.write "<tr><td align=center >"&htmlencode(CutStr(rs(3),16))&"("&rs(6)&"次)</td></tr>"
response.write "<tr><td align=center >"&rs2(0)&"</td></tr></table></td>"
if currentpage=totalpages then
if rs.eof then exit for
end if
if i mod 4=0 then
response.write"</tr>"
response.write"</table>"
end if
rs.movenext
next
%>
2.中间的代码是与我的数据库相连的,你改成与你的数据库相关参数就行了
3.代码贴如下:
<%
Dim totalPages,currentPage
Dim rs,sql
Dim PageSize
Set rs=server.createobject("adodb.recordset")
sql="select picID,filename,name,title,width,height,visitcount,classid,uptime,typeid from Photo order by visitcount desc"
rs.open sql,conn,1,1
response.write "<table border=0 width=""100%"" Class=DarkTableBody align=center >"
pagesize=20
rs.pagesize=pagesize
totalpages=rs.pagecount
currentPage=Request("page")
if currentpage="" Then currentpage=1
if not isNumeric(currentpage) Then
currentpage=1
ElseIf Cint(currentpage)>totalpages Then
currentpage=totalpages
End if
currentpage=Cint(currentpage)
rs.absolutepage=currentpage
for i=1 to pagesize
If rs.eof Then
if i mod 4=0 then'---每行显示的图片数量
response.write "<tr Class=LightTableBody >"
end if
EXIT FOR
End If
response.write "<td align=center height=""100%"">"&_
"<table width=""180"" height=""100%"" border=0 align=center>"&_
"<tr>"&_
"<td height=120 align=center ><table border=0 cellspacing=0 cellpadding=0 width=""100%"" height=""100%"" align=center ><tr><td align=center><A href=ClassAlbum.asp?CLassID="&rs("classid")&"&Action=ShowPhoto&PhotoID="&rs("picID")&" target=_blank ><img src="&StrVar(8)&rs(1)&" "&sizeadjust(rs(4),rs(5),110)&" border=0 ></a></td></tr></table></td></tr>"
response.write "<tr><td align=center >"&htmlencode(CutStr(rs(3),16))&"("&rs(6)&"次)</td></tr>"
response.write "<tr><td align=center >"&rs2(0)&"</td></tr></table></td>"
if currentpage=totalpages then
if rs.eof then exit for
end if
if i mod 4=0 then
response.write"</tr>"
response.write"</table>"
end if
rs.movenext
next
%>
展开全部
<%'开始分页
Const MaxPerPage=10
dim totalPut
dim CurrentPage
dim TotalPages
if Not isempty(request("page")) then
if request("page")="" then
currentPage=1
else
currentPage=Cint(request("page"))
end if
else
currentPage=1
end if
set rs=server.CreateObject("adodb.recordset")
rs.open "select id,id1,id2,biaoti,neirong,tupian,adddate,name,pic,address from shenheyi order by adddate desc",conn,1,1
if err.number<>0 then
response.write "<div align=center>暂无资料!</center>"
else
if rs.eof And rs.bof then
response.write "<div align=center>暂无资料!</center>"
else
totalPut=rs.recordcount
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
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
else
currentPage=1
end if
end if
i=0
%>
<table width="962" border="0" align="center">
<tr>
<%
do while not rs.eof
%>
<td width="20%" valign="top">
<table>
<tr><td>
<a href="read.asp?id=<%=rs("id")%>"><img src="<%=rs("tupian")%>" width='170' border='0'></a>
</td>
<td><strong><%=rs("biaoti")%></strong></td>
</tr>
</table>
</td>
<% i = i +1
rs.movenext
if rs.eof then exit do
loop
%>
</tr>
</table>
<%
rs.close
set rs=nothing
%>
还有疑问Q我吧
Const MaxPerPage=10
dim totalPut
dim CurrentPage
dim TotalPages
if Not isempty(request("page")) then
if request("page")="" then
currentPage=1
else
currentPage=Cint(request("page"))
end if
else
currentPage=1
end if
set rs=server.CreateObject("adodb.recordset")
rs.open "select id,id1,id2,biaoti,neirong,tupian,adddate,name,pic,address from shenheyi order by adddate desc",conn,1,1
if err.number<>0 then
response.write "<div align=center>暂无资料!</center>"
else
if rs.eof And rs.bof then
response.write "<div align=center>暂无资料!</center>"
else
totalPut=rs.recordcount
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
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
else
currentPage=1
end if
end if
i=0
%>
<table width="962" border="0" align="center">
<tr>
<%
do while not rs.eof
%>
<td width="20%" valign="top">
<table>
<tr><td>
<a href="read.asp?id=<%=rs("id")%>"><img src="<%=rs("tupian")%>" width='170' border='0'></a>
</td>
<td><strong><%=rs("biaoti")%></strong></td>
</tr>
</table>
</td>
<% i = i +1
rs.movenext
if rs.eof then exit do
loop
%>
</tr>
</table>
<%
rs.close
set rs=nothing
%>
还有疑问Q我吧
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
可以这样循环
<tr>
<%
i=1
do while not rs.eof
%>
<td><img src="<%=rs("图片地址")%>" width="宽度" height="高度"></td>
<%
if i mod 数字 = 0 then //(一行显示5个就写if i mod 5 = 0)
response.write("</tr><tr>")
end if
rs.movenext
i=i+1
loop
rs.close
%>
<tr>
<%
i=1
do while not rs.eof
%>
<td><img src="<%=rs("图片地址")%>" width="宽度" height="高度"></td>
<%
if i mod 数字 = 0 then //(一行显示5个就写if i mod 5 = 0)
response.write("</tr><tr>")
end if
rs.movenext
i=i+1
loop
rs.close
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
给你提个醒比如你表photo,列名为url
set rs=server.CreateObject("adodb.recordset")
rs.open"select * from photo",conn,1,1
if rs.eof and rs.bof then
response.writer"暂时没有图片"
else
%>
<tabale>
<tr>
<%for i=1 to rs.recordcunt%>
<td><img src="<%=rs("url")%>"></td>
<%
if i mod 5=0 then response.writer"</tr><tr>"
rs.movenext
if rs.eof then exit for
next
end if
rs.close
set rs=nothing
%>
%>
</tr>
</table>
不会了找我
set rs=server.CreateObject("adodb.recordset")
rs.open"select * from photo",conn,1,1
if rs.eof and rs.bof then
response.writer"暂时没有图片"
else
%>
<tabale>
<tr>
<%for i=1 to rs.recordcunt%>
<td><img src="<%=rs("url")%>"></td>
<%
if i mod 5=0 then response.writer"</tr><tr>"
rs.movenext
if rs.eof then exit for
next
end if
rs.close
set rs=nothing
%>
%>
</tr>
</table>
不会了找我
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询