求ASP静态列表页的生成代码,该怎么解决
求ASP静态列表页的生成代码
下图为静态页的列表页, 图片从数据库中循环查询出来,显示在页面上,用双重循环实现,外循环控制页数,内循环控制每页显示多少图片以及每行显示几张图片
手动添加的:
程序执行后的结果:
现在的问题是: (1)不管有多少页,每页都显示相同的图片;(2)页码错误,1/3,前边的数字是当前页,所有页都显示这样
代码
下图为静态页的列表页, 图片从数据库中循环查询出来,显示在页面上,用双重循环实现,外循环控制页数,内循环控制每页显示多少图片以及每行显示几张图片
手动添加的:
程序执行后的结果:
现在的问题是: (1)不管有多少页,每页都显示相同的图片;(2)页码错误,1/3,前边的数字是当前页,所有页都显示这样
代码
- VB code
<table width="96%" height="89" border="0" cellpadding="0" cellspacing="0"> <tr> <td>生成行程列表</td> </tr> <tr> <td> <%dbdns=""%> <!--#include file="inc/conn.asp"--> <% '取模板 'response.write request("id") 'response.end sql="select * from template where id=4" rs.open sql,conn,1,1 templatecontent=rs("content") '取行程 tabl="<table width=980 border=0 cellspacing=20 cellpadding=0><tr><td width=300><table width=980 border=0 cellspacing=20 cellpadding=0>" 'table="</td></tr></table>" 'sql="select top 20 ysj_zp.图片,ysj_zp.类别,ysj.姓名,ysj_zp.lid,ysj_zp.id,ysj.类别 from ysj_zp inner join ysj on ysj.id=ysj_zp.lid where ysj_zp.类别='摄影' order by ysj_zp.id desc" set rs=server.CreateObject("adodb.recordset") sql="select Travel.TravelName,Travel.LocationIntroduction,Travel.TravelIntroduction,Travel.TravelPrice,Travel.Id,Travel.addtime,TravelPhoto.TravelId,Travel.TourismCategory,TravelPhoto.Photo from Travel inner join TravelPhoto on Travel.id=TravelPhoto.TravelID where Travel.TourismCategory='"&request("id")&"'" 'sql="select Travel.Id,TravelPhoto.TravelId from Travel inner join TravelPhoto on Travel.id=TravelPhoto.TravelID" 'sql="select distinct(TravelId),Photo,PhotoTitle,Photo_text from TravelPhoto" rs.open sql,conn,1,1 select case request("id") case 81 fil="Citytour" case 82 fil="GreatWall" case 83 fil="Culturetour" case 84 fil="Bustour" case 85 fil="packagetour" end select 'fil=year(rs("addtime"))&month(rs("addtime"))&day(rs("addtime")) if rs.recordcount/4=int(rs.recordcount/4) then countpage=rs.recordcount/4 else countpage=int(rs.recordcount/4)+1 end if for j=1 to countpage pages= pages &"<a href="&fil&"_"&j&".htm>["&j&"]</a> " next k=1 for j=1 to countpage if rs.recordcount<j*4 then endfor=rs.recordcount else endfor=j*4 end if 'response.write ((j-1)*4+1)&"___"&endfor&"<br>" for i=(j-1)*4+1 to endfor if k mod 3 = 1 then tabl=tabl&"<tr>" end if 'response.write i&"___"&endfor&"<br>" tabl=tabl&"<td width=300><table width=281 height=361 border=0 cellpadding=0 cellspacing=0><tr><td valign=top><table width=100% border=0 cellspacing=0 cellpadding=0><tr><td><img src=../admin/Travel/uploadimage/"&rs("photo")&" width=281 height=191 /></td></tr></table><table width=100% border=0 cellpadding=0 cellspacing=10 bgcolor=#fafafa><tr><td><table width=100% border=0 cellspacing=0 cellpadding=0><tr><td height=40 class=huang30>"&rs("TravelName")&rs("id")&"_"&i&"_"&j&countpage&"</td></tr><tr><td class=lan16><table width=100% border=0 cellspacing=0 cellpadding=0><tr><td class=lan14>"&rs("LocationIntroduction")&"</td><td align=right><a href="&rs("TravelName")&".htm target=_blank><img src=../images/more.jpg width=36 height=11 border=0/></a></td></tr></table></td></tr><tr><td height=20><img src=../images/lanxuxian.gif height=1 /></td></tr><tr><td><table width=261 border=0 cellspacing=0 cellpadding=0><tr><td width=70><img src=../images/minpic.gif width=57 height=57 /></td><td valign=top>"&left(rs("TravelIntroduction"),90)&"</td></tr></table></td></tr></table></td></tr></table><table width=100% height=49 border=0 cellpadding=0 cellspacing=0><tr><td align=center background=../images/bg4.gif class=bai16>$<span class=STYLE1>"&rs("TravelPrice")&"</span> | <span class=STYLE1>$TravelTime$</span> | <span class=STYLE1>)</span>hours</td></tr></table></td></tr></table></td>" k=k+1 rs.movenext next tabl=tabl&"</table></td></tr></table>" templatecontent=replace(templatecontent,"$title$",title) templatecontent=replace(templatecontent,"$keywords$",keyword) templatecontent=replace(templatecontent,"$list$",tabl) templatecontent=replace(templatecontent,"$Pages$",j &"/"&countpage &pages) '此处的j 为当前页,但总是显示1 response.write templatecontent '创建动态生成的页 set fso=server.createobject("scripting.filesystemobject") set htmlwrite=fso.createtextfile(server.mappath("travel/"&fil&"_"&j&".htm"),true) htmlwrite.writeline templatecontent htmlwrite.close next 'response.write "生成行程列表成功" '释放文件系统对象 set htmlwrite=nothing set fso=nothing %> <!--<script>alert('生成行程列表成功');history.back(-1)</script> --> </td> </tr> <tr> <td> </td> </tr> </table>