日期:2014-05-17  浏览次数:20992 次

求ASP静态列表页的生成代码
下图为静态页的列表页, 图片从数据库中循环查询出来,显示在页面上,用双重循环实现,外循环控制页数,内循环控制每页显示多少图片以及每行显示几张图片

手动添加的:


程序执行后的结果:


现在的问题是: (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>"&a