asp简单分页

 

< %@LANGUAGE = " VBSCRIPT "  CODEPAGE = " 65001 " % >
 
< ! --  #include file = " conn.asp "   -->
< %
set  rs = server.CreateObject( " adodb.recordset " )
sql
= " select * from Student "
rs.open sql,conn,
1 , 1  

rs.pagesize
= 5
if  request( " page " ) <> ""   then
  page 
=   cint (request( " page " ))
   
if  page < 1   then  page = 1
   
if  page > rs.pagecount  then  page = rs.pagecount
else
page
= 1
end   if
rs.absolutepage
= page

%
>
< html >
< head >
< meta http - equiv = " Content-Type "  content = " text/html; charset=utf-8 "   />

< title > 无标题文档 </ title >

</ head >

< body >

< form name = " form1 "  method = " post "  action = "" >
  
< table width = " 418 "  border = " 1 " >
    
< tr >
      
< td > ID </ td >
      
< td > 姓名 </ td >
      
< td > 性别 </ td >
      
< td > 年龄 </ td >
      
< td > 操作 </ td >
    
</ tr >
    
< %
for  i = 0   to  rs.pagesize - 1
if  rs.bof  or  rs.eof  then   exit   for
%
>
    
< tr >
      
< td >< % = rs( " Id " )% ></ td >
      
< td >< % = rs( " UserName " )% ></ td >
      
< td >< % = rs( " Age " )% ></ td >
      
< td >< % = rs( " Sex " )% ></ td >
      
< td >
      
< a ></ a >    
      
< a href = "http://www.jscss8.com/ baomingDelete.asp?id=<%=rs( " Id " )%>&page=<%=page%> "  onClick = " return confirm('确定删除吗?') " > 删除 </ a >
      
</ td >
    
</ tr >
    
< %
    rs.movenext()
    
next
    %
>
    
< tr >
      
< td colspan = " 5 " >
 
< p align = " center " >
< a href = "http://www.jscss8.com/ baomingList.asp?page=1 " > 首页 </ a >& nbsp;
< a href = "http://www.jscss8.com/ baomingList.asp?page=<%=page-1%> " > 前一页 </ a >& nbsp;
< a href = "http://www.jscss8.com/ baomingList.asp?page=<%=page+1%> " > 后一页 </ a >& nbsp;
< a href = "http://www.jscss8.com/ baomingList.asp?page=<%=rs.pagecount%> " > 末页 </ a >
</ p >
< p align = " center " > 现在是第 < % = page% > 页一共有 < % = rs.pagecount% > </ p >
      
</ td >
    
</ tr >
  
</ table >
</ form >
< %
rs.close
set  rs = nothing  
conn.close()
%
>
</ body >
</ html >

 

 


 

你可能感兴趣的:(asp)