asp 多行多列加分页代码

<%
'=================================================
'过程名:ShowProductTotal
'作  用:显示文章总数
'参  数:无
'=================================================
sub ShowProductTotal()
 dim sqlTotal
 dim rsTotal
 sqlTotal="select Count(*) from Ok3w_User where IsLock=0 " 
 Set rsTotal= Server.CreateObject("ADODB.Recordset")
 rsTotal.open sqlTotal,conn,1,1
 if rsTotal.eof and rsTotal.bof then
  totalPut=0
  response.write "共有 0 个作品"
 else
  totalPut=rsTotal(0)
  
 end if
 rsTotal.close
 set rsTotal=nothing
end sub


sub Showprojectorgift(TitleLen,numflag)
dim flagstr
if numflag=1 then
 flagstr="qichesj.asp"
else
 flagstr="qichesj.asp"
end if
if TitleLen<0 or TitleLen>200 then
  TitleLen=50
 end if
    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
        sqlProduct="select top " & MaxPerPage 
 else
  sqlProduct="select "
 end if
 sqlProduct=sqlProduct & " ID,name,tel,address,web,photo,user_name from Ok3w_User where IsLock=0 "
 sqlProduct=sqlProduct & " order by id desc"
 
 Set rs= Server.CreateObject("ADODB.Recordset")
 rs.open sqlProduct,conn,1,1
 
 if rs.bof and  rs.eof then
  response.Write("<br><li>没有任何汽车商家</li>")
 else
  if currentPage=1 then
   call ProdContent(TitleLen,flagstr)
  else
   if (currentPage-1)*MaxPerPage<totalPut then
              rs.move  (currentPage-1)*MaxPerPage
           dim bookmark
             bookmark=rs.bookmark
             call ProdContent(TitleLen,flagstr)
         else
          currentPage=1
             call ProdContent(TitleLen,flagstr)
      end if
  end if
 end if
 rs.close
 set rs=nothing
end sub
sub ProdContent(TitleLen,flag)
dim strhtml
i=0
dim i,strTemp,strTemp1,strTemp2
 strTemp1="<table width=""98%"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0""><tr>" 
 do while not rs.eof
  strTemp=strTemp&"<td align=""center"">"
  strTemp=strTemp&"<table width=""223"" height=""134"" border=""0"" cellpadding=""0"" cellspacing=""1"" bgcolor=""#E1E1E1"">"
  strTemp=strTemp&"<tr>"
  strTemp=strTemp&"<td width=""221"" bgcolor=""#FFFFFF"">"
  strTemp=strTemp&"<table width=""90%"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"">"
  strTemp=strTemp&"<tr>"
  strTemp=strTemp&"<td width=""65%"" align=""left"" class=""new""><a href=""qichesj_back.asp?inputer='"&rs("user_name")&"'&ID="&rs("id")&""" target=""_blank"" class=""new"">"&rs("name")&"</a></td>"
  strTemp=strTemp&"<td width=""35%"" rowspan=""2"" align=""center"" valign=""top""><img src="""&rs("photo")&""" width=""66"" height=""48"" /></td>"
  strTemp=strTemp&"</tr>"
  strTemp=strTemp&"<tr align=""left"" class=""nnn"">"
  strTemp=strTemp&"<td>电话:"&rs("tel")&"</td>"
  strTemp=strTemp&"</tr>"
  strTemp=strTemp&"<tr align=""left"" class=""nnn"">"
  strTemp=strTemp&"<td colspan=""2"">地址:"&rs("address")&"</td>"
  strTemp=strTemp&"</tr>"
  strTemp=strTemp&"<tr align=""left"" class=""nnn"">"
  strTemp=strTemp&"<td colspan=""2"">网址:"&rs("web")&"</td>"
  strTemp=strTemp&"</tr>"
  strTemp=strTemp&"</table>"
  strTemp=strTemp&"</td>"
  strTemp=strTemp&"</tr>"
  strTemp=strTemp&"</table>"
  strTemp=strTemp&"</td>"
  i=i+1
  if i mod 4=0 then
   strTemp2=strTemp2&"<table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0""><tr><td>&nbsp;</td></tr></table>"&strTemp1&strTemp&"</tr></table>"
   strTemp=""
  end if
  rs.movenext
  if i+1>MaxPerPage then exit do
 loop

 if(totalPut-((currentPage-1)*MaxPerPage))<MaxPerPage then
  strTemp=strTemp2&"<table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0""><tr><td>&nbsp;</td></tr></table>"&strTemp1&strTemp&"</tr></table>"
 else
  strTemp=strTemp2
 end if
 response.Write(strTemp)
end sub

'***********************************************
'过程名:showpage
'作  用:显示“上一页 下一页”等信息
'参  数:sfilename  ----链接地址
'       totalnumber ----总数量
'       maxperpage  ----每页数量
'       ShowTotal   ----是否显示总数量
'       ShowAllPages ---是否用下拉列表显示所有页面以供跳转。有某些页面不能使用,否则会出现JS错误。
'       strUnit     ----计数单位
'***********************************************
sub showpage(sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit)
 
 dim n, i,strTemp,strUrl
 if totalnumber mod maxperpage=0 then
     n= totalnumber \ maxperpage
   else
     n= totalnumber \ maxperpage+1
   end if
   strTemp= "<table align='center' style='font-size:12px;'><form name='showpages' method='Post' action='" & sfilename & "'><tr><td>"
 if ShowTotal=true then
  strTemp=strTemp & "共 <b>" & totalnumber & "</b> " & strUnit & "&nbsp;&nbsp;"
 end if
 strUrl=JoinChar(sfilename)
   if CurrentPage<2 then
      strTemp=strTemp & "首页 上一页&nbsp;"
   else
      strTemp=strTemp & "<a href='" & strUrl & "page=1'>首页</a>&nbsp;"
      strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage-1) & "'>上一页</a>&nbsp;"
   end if

   if n-currentpage<1 then
      strTemp=strTemp & "下一页 尾页"
   else
      strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage+1) & "'>下一页</a>&nbsp;"
      strTemp=strTemp & "<a href='" & strUrl & "page=" & n & "'>尾页</a>"
   end if
    strTemp=strTemp & "&nbsp;页次:<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
    strTemp=strTemp & "&nbsp;<b>" & maxperpage & "</b>" & strUnit & "/页"
 if ShowAllPages=True then
  strTemp=strTemp & "&nbsp;转到:<select name='page' size='1' onchange='javascript:submit()'>"  
     for i = 1 to n  
      strTemp=strTemp & "<option value='" & i & "'"
   if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
   strTemp=strTemp & ">第" & i & "页</option>"  
     next
  strTemp=strTemp & "</select>"
 end if
 strTemp=strTemp & "</td></tr></form></table>"
 response.write strTemp 
end sub
'***********************************************
function JoinChar(strUrl)
 if strUrl="" then
  JoinChar=""
  exit function
 end if
 if InStr(strUrl,"?")<len(strUrl) then
  if InStr(strUrl,"?")>1 then
   if InStr(strUrl,"&")<len(strUrl) then
    JoinChar=strUrl & "&"
   else
    JoinChar=strUrl
   end if
  else
   JoinChar=strUrl & "?"
  end if
 else
  JoinChar=strUrl
 end if
end function
%>

数据调用 <%
  if request("page")<>"" then
    currentPage=cint(request("page"))
else
 currentPage=1
end if
MaxPerPage=16
strFileName="qichesj.asp"
dim totalPut
 call ShowProductTotal()
  call Showprojectorgift(35,1)
 %>

分页调用

<%if totalput>0 then     
     call showpage(strFileName,totalput,MaxPerPage,true,true,"个汽车商家")
    end if%>

posted @ 2011-08-31 10:30  火精灵  阅读(167)  评论(0编辑  收藏  举报