|
我自己写的代码,是通过选择年份来查询成员.可无法查找出记录,只能显示上一页下一页那几个导航,求助高手帮忙!!
以下是主要代码
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp" -->
<%
dim sql,pgno,pgsz,pgct
sql="select * from mytable where year="&Cint(request.QueryString("year") )
set rs=server.CreateObject("adodb.recordset")
rs.pagesize=2
rs.open sql,conn,1,1
if rs.eof then '如果没有相应记录
response.write "对不起,没有匹配的记录<br>"
end if
last=rs.recordcount mod rs.pagesize '最后一页是否有记录
if last=0 then
pgct=int(rs.recordcount/rs.pagesize)
else pgct=int(rs.recordcount/rs.pagesize)+1
end if
pgno=request.QueryString("pgno") '取得当前页
if pgno=""or pgno<1 then
pgno=1
end if
do while not rs.eof and rs.bof '如果有记录
rs.absolutepage=page
response.Write"<table width=335 border=0 align=center cellpadding=0 cellspacing=2 class=table>" '以表格显示记录
response.Write"<tr><td>姓名:</td></tr><tr><td>"&rs("name")&"</td></tr>"
response.Write"<tr><td>性别:</td></tr><tr><td>"&rs("sex")&"</td></tr>"
rs.movenext
pgno=pgno+1
loop
rs.close()
set rs=nothing
conn.close
set conn=nothing
response.write"<div align=center><a href=search.asp?pgno="
response.write pgno-1
response.write">上一页</a> <a href=search.asp?pgno="
response.write pgno+1
response.write">下一页</a> <a href=search.asp?pgno=1>第一页</a>"
response.write"<a href=search.asp?pgno="
response.write pgct
response.write"> 最后一页</a> 共"
response.write pgct
response.write"页 当前为第"
response.write pgno
%>页</td> |
|