字段中的图片分页显示

magic_jason 2009-08-13 05:59:25
是这样的我在数据库中一个图片字段中上传了多张图片,格式为 *a.jpg*b.jpg*c.jpg
想要分割之后在前台分页显示(每页显示10张图),所以想请问一下各位高手,怎么样利用字段里的图片数来分页显示
希望大家多帮忙了
...全文
76 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
toury 2009-08-13
  • 打赏
  • 举报
回复
<P align="center" class="STYLE2">第 <%=currentpage%>页 共 <%=n%>页 共 <%=m%>张图片
<% k=currentPage
------>
<P align="center" class="STYLE2">第 <%=page%>页 共 <%=n%>页 共 <%=m%>张图片
<% k=page
toury 2009-08-13
  • 打赏
  • 举报
回复

<%
s=rs("图片字段")
arr=split(s,",")
m=ubound(arr)
n=cint(m/10)+1

page=request("page")
if page="" then page=1
page=cint(page)
t=(page-1)*10
response.write "<table border=1>"
for i=t to (t+9)
response.write"<tr>"
response.write"<td><img src='"&arr(i)&"'></td>"
if (i+1) mode 5=0 then
response.write"</tr><tr>"
end if
response.write"</tr>"
next
response.write"</table>"

%>
<P align="center" class="STYLE2">第 <%=currentpage%>页 共 <%=n%>页 共 <%=m%>张图片
<% k=currentPage
if k <>1 then
response.write "[ <b>"+" <a href='photo.asp?page=1'>首页 </a> </b>] "
response.write "[ <b>"+" <a href='photo.asp?page="+cstr(k-1)+"'>上一页 </a> </b>] "
else
Response.Write "[首页] [上一页]"
end if
if k <>n then
response.write "[ <b>"+" <a href='photo.asp?page="+cstr(k+1)+"'>下一页 </a> </b>] "
response.write "[ <b>"+" <a href='photo.asp?page="+cstr(n)+"'>尾页 </a> </b>] "
else
Response.Write "[下一页] [尾页]"
end if
%>
</P>



大致如此,你自己斟酌加工一下吧。我只是一个思路,随手敲的代码,难免错误
magic_jason 2009-08-13
  • 打赏
  • 举报
回复
2楼的兄弟,你贴的是读取图片表里的数据,我问的是图片都在一个字段里啊,用split分割读取出来的怎么分页
liuwei_IT_love 2009-08-13
  • 打赏
  • 举报
回复
<%
dim str,rs
str="select * from pic order by id desc"
set rs=server.CreateObject("ADODB.Recordset")
rs.open str,db,1
if not rs.bof and not rs.eof then
Dim totalPut,CurrentPage
rs.PageSize=16 ‘每页显示总条数
rs.MoveFirst
howmanyfields=rs.Fields.Count-1
If trim(Request("Page"))<>"" then
CurrentPage= CLng(request("Page"))
If CurrentPage> rs.PageCount then
CurrentPage = rs.PageCount '显示总页数
End If
Else
CurrentPage= 1
End If
if rs.eof then
response.write "<p align='center'> ERROR!</p>"
else
totalPut=rs.recordcount '显示总记录数
if CurrentPage<>1 then
if (currentPage-1)*rs.pagesize<totalPut then
rs.move(currentPage-1)*rs.pagesize
dim bookmark
bookmark=rs.bookmark '返回书签
end if
end if
dim t
t=rs.PageSize/4
Do While Not rs.Eof And t>0
t=t-1
%>
<TABLE border=0 align=center>
<tr>
<%
for i=1 to 4
If Not rs.Bof And Not rs.Eof Then
%>
<TD><B><a href="photo_intro.asp?id=<%=rs("id")%>"><img src="<%=rs("pic")%>" width="200" height="150" border="0"/></a></B></TD>
<%
else
exit for
end if
rs.MoveNext
next
%></tr>
</TABLE>
<%
loop
end if
dim n,k
if (totalPut mod rs.pagesize)=0 then
n= totalPut \rs.pagesize
else
n= totalPut \ rs.pagesize+1
end if
%>
<P align="center" class="STYLE2">第<%=currentpage%>页 共<%=n%>页 共<%=rs.recordcount%>条纪录
<% k=currentPage
if k<>1 then
response.write "[<b>"+"<a href='photo.asp?page=1'>首页</a></b>] "
response.write "[<b>"+"<a href='photo.asp?page="+cstr(k-1)+"'>上一页</a></b>] "
else
Response.Write "[首页] [上一页]"
end if
if k<>n then
response.write "[<b>"+"<a href='photo.asp?page="+cstr(k+1)+"'>下一页</a></b>] "
response.write "[<b>"+"<a href='photo.asp?page="+cstr(n)+"'>尾页</a></b>] "
else
Response.Write "[下一页] [尾页]"
end if
Response.Write "[<a href='index.asp' target='_parent'>返回主页</a>]"
%>
</P>
<span class="STYLE2">
<%
end if
rs.close
set rs=nothing
%>
magic_jason 2009-08-13
  • 打赏
  • 举报
回复
哪位大侠出来帮个忙,急用

28,406

社区成员

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

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