200分:求解决asp中用For循环输出分页图片列表
我想实现产品按类别自动生成html,并且如果某类产品有三页,就自动生成Cap_1.html,Cap_2.html,Cap_3.html。我现在的程序好像for循环处理不当...
我想实现产品按类别自动生成html,并且如果某类产品有三页,就自动生成Cap_1.html,Cap_2.html,Cap_3.html。我现在的程序好像for循环处理不当,只能生成一个类别,并且只有一页。
求高手指点,解决后,分数可以追加到200分.
<%
Set Rs_class=conn.execute("select bigclass_id,en_bigclassname from productbigclass") '产品分类
Rsclass=Rs_class.GetRows()
Rows_count=Ubound(Rsclass,2)
Rs_class.close
set Rs_class=nothing
for c=0 to Rows_count '根据所以分类名称输出html
For s=1 to R '输入页码数 cap_1.html,cap_2.html
bigclassid=Rsclass(0,c)
bigclassname=Rsclass(1,c)
Filen = "../html_mb/productlist_mb.html" '模板文件
sFilen ="../htm/"&Trim(replace(bigclassname," ","-"))&"-"&s&".html" '生成的文件名
Content = ReadFormUTF(Filen,"utf-8") '读取模板
left_menu= ShowProductList(bigclassid)
dim big_id,rs,product_sql,bigclassname,title,oStr
set rs=server.createobject("ADODB.recordset") '输出图片列表
product_sql="select id,bigclass_id,en_title,pic from Product_Info where bigclass_id='"&bigclassid&"' order by en_title desc"
Rs.PageSize = 30 '每页条数
Rs.CursorLocation = 3
rs.open product_sql,conn,1,1
oStr=""
if rs.bof and rs.eof then
oStr= oStr & "Don't have any products, Please wait for a while!"
response.end
end if
oStr= oStr & "<div id='img'>" & vbCrlf
Dim pages,intpage,ls,j
intpage = cint(request.QueryString("page")) '获取页码
pages = Rs.PageCount '总页数
if cint(intpage) < 1 then intpage = 1
if cint(intpage) > Rs.PageCount then intpage = Rs.PageCount
rs.AbsolutePage = intpage '指定记录集页码
ls = 5 '指定列数
'--行循环开始
for i=1 to int(Rs.PageSize / ls) '行数
if Rs.Eof then exit for '控制行的输出
oStr= oStr & "<ul>"
'--列循环开始
for j=1 to ls '控制列的输出
if Not Rs.Eof then
'//要输出的内容
oStr= oStr & "<li>"& vbCrlf
oStr= oStr & "---------------"& vbCrlf
oStr= oStr & "</li>"
'//内容结束
Rs.movenext
else
oStr= oStr & "<p> </p>"
end if
next
oStr= oStr & "</ul>" & vbCrlf
if (i*j)=Rs.PageSize then exit for '如果每页达到30写入html
next
oStr= oStr & "</div>"& vbCrlf
oStr= oStr & "<br style='clear:both;' />"
oStr= oStr & "<span style='display:block;text-align:right;background-color: #f1f1f1' />"
oStr= oStr & " "&s-1&" "&s&" "&s+1" '输出分页页码
oStr= oStr & "</span>"
'生成html
content=replace(content,"{left_menu}",left_menu)
content=replace(content,"{images}",oStr)
Call WriteToUTF(content,sFilen) '//生成静态页
next
R=R+1
next
response.write s&".成功生成: "&replace(bigclassname," ","-")&"-"&s&".html"
%>
因为内容太多,还有两个函数就不附上了。
R是页数,也就是生成静态页的次数,每生成一次循环一次,如果是2说明应该有两页,那就是Cap_1.html,Cap_2.html,R好像要赋个初始值R=1.
chengjitao,你可能不知道,发布问题时最多只能给100分,但可以追加到200分,但没有正确答案我追加什么,没有人能搞定我不白白扔到水里了,我都扔过好几次了,如果你能搞定,我保证给你200分。 展开
求高手指点,解决后,分数可以追加到200分.
<%
Set Rs_class=conn.execute("select bigclass_id,en_bigclassname from productbigclass") '产品分类
Rsclass=Rs_class.GetRows()
Rows_count=Ubound(Rsclass,2)
Rs_class.close
set Rs_class=nothing
for c=0 to Rows_count '根据所以分类名称输出html
For s=1 to R '输入页码数 cap_1.html,cap_2.html
bigclassid=Rsclass(0,c)
bigclassname=Rsclass(1,c)
Filen = "../html_mb/productlist_mb.html" '模板文件
sFilen ="../htm/"&Trim(replace(bigclassname," ","-"))&"-"&s&".html" '生成的文件名
Content = ReadFormUTF(Filen,"utf-8") '读取模板
left_menu= ShowProductList(bigclassid)
dim big_id,rs,product_sql,bigclassname,title,oStr
set rs=server.createobject("ADODB.recordset") '输出图片列表
product_sql="select id,bigclass_id,en_title,pic from Product_Info where bigclass_id='"&bigclassid&"' order by en_title desc"
Rs.PageSize = 30 '每页条数
Rs.CursorLocation = 3
rs.open product_sql,conn,1,1
oStr=""
if rs.bof and rs.eof then
oStr= oStr & "Don't have any products, Please wait for a while!"
response.end
end if
oStr= oStr & "<div id='img'>" & vbCrlf
Dim pages,intpage,ls,j
intpage = cint(request.QueryString("page")) '获取页码
pages = Rs.PageCount '总页数
if cint(intpage) < 1 then intpage = 1
if cint(intpage) > Rs.PageCount then intpage = Rs.PageCount
rs.AbsolutePage = intpage '指定记录集页码
ls = 5 '指定列数
'--行循环开始
for i=1 to int(Rs.PageSize / ls) '行数
if Rs.Eof then exit for '控制行的输出
oStr= oStr & "<ul>"
'--列循环开始
for j=1 to ls '控制列的输出
if Not Rs.Eof then
'//要输出的内容
oStr= oStr & "<li>"& vbCrlf
oStr= oStr & "---------------"& vbCrlf
oStr= oStr & "</li>"
'//内容结束
Rs.movenext
else
oStr= oStr & "<p> </p>"
end if
next
oStr= oStr & "</ul>" & vbCrlf
if (i*j)=Rs.PageSize then exit for '如果每页达到30写入html
next
oStr= oStr & "</div>"& vbCrlf
oStr= oStr & "<br style='clear:both;' />"
oStr= oStr & "<span style='display:block;text-align:right;background-color: #f1f1f1' />"
oStr= oStr & " "&s-1&" "&s&" "&s+1" '输出分页页码
oStr= oStr & "</span>"
'生成html
content=replace(content,"{left_menu}",left_menu)
content=replace(content,"{images}",oStr)
Call WriteToUTF(content,sFilen) '//生成静态页
next
R=R+1
next
response.write s&".成功生成: "&replace(bigclassname," ","-")&"-"&s&".html"
%>
因为内容太多,还有两个函数就不附上了。
R是页数,也就是生成静态页的次数,每生成一次循环一次,如果是2说明应该有两页,那就是Cap_1.html,Cap_2.html,R好像要赋个初始值R=1.
chengjitao,你可能不知道,发布问题时最多只能给100分,但可以追加到200分,但没有正确答案我追加什么,没有人能搞定我不白白扔到水里了,我都扔过好几次了,如果你能搞定,我保证给你200分。 展开
5个回答
展开全部
这里和你的类似,你需要两次读取数据库,第一次读出记录总数,第二个循环输出,中间用一个参数在控制次数,你只需要把中间的改成你的输出内容即可:
<%
sql="select * from product_info"
set rs=server.createObject("ADODB.Recordset")
rs.open sql,conn,1,1
%><%
rs.pagesize=30
totalpage=rs.pagecount
rs.close
set rs=nothing
for j=1 to totalpage
sql="select * from product_info"
set rs=server.createObject("ADODB.Recordset")
rs.open sql,conn,1,1
whichpage=j
rs.pagesize=30
totalpage=rs.pagecount
rs.absolutepage=whichpage
howmanyrecs=0
%><%
str0=""
str0=str0&"</p>"
str0=str0&"<table bgcolor=#cecfce align=center border=0 width=800 cellpadding=2 cellspacing=1>"
%><%
do while not rs.eof and howmanyrecs<rs.pagesize
%><%
str0=str0&"<tr bgcolor=#f7f7f7>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(0)&"</td>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(1)&"</td>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(2)&"</td>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(3)&"</td>"
str0=str0&"</tr>"
%><%
rs.movenext
howmanyrecs=howmanyrecs+1
loop
rs.close
set rs=nothing
%><%str0=str0&"</table>"
%><%
'分页部分
ref=""
ref=ref&"<br>"
ref=ref&"<table bgcolor=#cecfce align=center border=0 width=800 cellpadding=0 cellspacing=1> "
ref=ref&"<tr bgcolor=#f7f7f7>"
ref=ref&"<td> "
ref=ref&"<b>Pages: " & j & " / " & totalpage &"</b>"
ref=ref&"</td>"
ref=ref&"<td> "
ref=ref&"<a href=list_1.html"&">" & "<FONT face=Webdings>9</FONT>" & "</a> "
if whichpage=1 then
ref=ref&"<FONT face=Webdings>7</FONT>"
else
ref=ref&"<a href=list_"&j-1&".html"&">" & "<FONT face=Webdings>7</FONT>" & "</a> "
end if
for counter=1 to totalpage
ref=ref&"<a href=list_"&counter&".html"&">[" & counter & "]</a>"
ref=ref& " "
if counter mod 10 = 0 then
ref=ref& "<br>"
end if
next
if (whichpage>totalpage or whichpage=totalpage) then
ref=ref&"<FONT face=Webdings>8</FONT>"
else
ref=ref&"<a href=list_"&j+1&".html"&">" & "<FONT face=Webdings>8</FONT>" & "</a> "
end if
ref=ref&"<a href=list_"&totalpage&".html"&">" & "<FONT face=Webdings>:</FONT>" & "</a> "
<%
sql="select * from product_info"
set rs=server.createObject("ADODB.Recordset")
rs.open sql,conn,1,1
%><%
rs.pagesize=30
totalpage=rs.pagecount
rs.close
set rs=nothing
for j=1 to totalpage
sql="select * from product_info"
set rs=server.createObject("ADODB.Recordset")
rs.open sql,conn,1,1
whichpage=j
rs.pagesize=30
totalpage=rs.pagecount
rs.absolutepage=whichpage
howmanyrecs=0
%><%
str0=""
str0=str0&"</p>"
str0=str0&"<table bgcolor=#cecfce align=center border=0 width=800 cellpadding=2 cellspacing=1>"
%><%
do while not rs.eof and howmanyrecs<rs.pagesize
%><%
str0=str0&"<tr bgcolor=#f7f7f7>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(0)&"</td>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(1)&"</td>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(2)&"</td>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(3)&"</td>"
str0=str0&"</tr>"
%><%
rs.movenext
howmanyrecs=howmanyrecs+1
loop
rs.close
set rs=nothing
%><%str0=str0&"</table>"
%><%
'分页部分
ref=""
ref=ref&"<br>"
ref=ref&"<table bgcolor=#cecfce align=center border=0 width=800 cellpadding=0 cellspacing=1> "
ref=ref&"<tr bgcolor=#f7f7f7>"
ref=ref&"<td> "
ref=ref&"<b>Pages: " & j & " / " & totalpage &"</b>"
ref=ref&"</td>"
ref=ref&"<td> "
ref=ref&"<a href=list_1.html"&">" & "<FONT face=Webdings>9</FONT>" & "</a> "
if whichpage=1 then
ref=ref&"<FONT face=Webdings>7</FONT>"
else
ref=ref&"<a href=list_"&j-1&".html"&">" & "<FONT face=Webdings>7</FONT>" & "</a> "
end if
for counter=1 to totalpage
ref=ref&"<a href=list_"&counter&".html"&">[" & counter & "]</a>"
ref=ref& " "
if counter mod 10 = 0 then
ref=ref& "<br>"
end if
next
if (whichpage>totalpage or whichpage=totalpage) then
ref=ref&"<FONT face=Webdings>8</FONT>"
else
ref=ref&"<a href=list_"&j+1&".html"&">" & "<FONT face=Webdings>8</FONT>" & "</a> "
end if
ref=ref&"<a href=list_"&totalpage&".html"&">" & "<FONT face=Webdings>:</FONT>" & "</a> "
展开全部
说200分,怎么我看到的只有100啊。。。
冲你不诚实,可能就没人回答哦。。。
冲你不诚实,可能就没人回答哦。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
程序层次难的看啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
For s=1 to R
这里的R的数字是从哪里得来的?
这里的R的数字是从哪里得来的?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询