?? pagequary.asp
字號:
<%@ Language=VBScript %>
<!--#include FILE="adovbs.inc"-->
<%Response.Buffer=true%>
<html>
<head>
<link rel="stylesheet" href="../html/3508.css">
<style type="text/css">
<!--
.green { color: #006600}
.red { color: #FF0000}
-->
</style>
</head>
<body background="../images/bg1.gif">
<p><OBJECT RUNAT=server PROGID=ADODB.Connection id=con>
</OBJECT><%
con.open application("DBCon_ConnectionString")
'con.Open "PROVIDER=SQLOLEDB;DATA SOURCE=server;UID=sa;PWD=;DATABASE=3058 "
'read in the curpage
currentPage=cint(Request.QueryString("currentPage"))
'read in the querystring
sqlstr=Request.QueryString("sqlstr")
'Response.Write("sqlstr:"& sqlstr &"<p>") 'for debug use
'Response.Write("pagesize:"& cstr(mPAGESIZE) &"<p>") 'for debug use
'open recordset
set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorType = adOpenStatic
rs.PageSize= mPAGESIZE
rs.Open sqlstr,con
'Response.Write("currentPage:" & currentPage &" page count:" & rs.PageCount ) 'for debug
pagenum=int(rs.RecordCount/mPAGESIZE)
'Response.Write("rs.recordcount:" & rs.RecordCount &"<br>")
'Response.Write("pagenum:"& pagenum &"<p>")
if rs.EOF then 'when no record is pick out
Response.Redirect("./quaryfail.htm")
end if
%></p>
<table width="740" border="0" cellspacing="0" cellpadding="0" align="center" height="40">
<tr>
<td width="217" height="39" align="center" valign="bottom"><img src="../images/smallmark.gif" width="120" height="25"></td>
<td width="523" valign="bottom" height="39"><a href="../default.asp">本站首頁</a>
>> 查詢結果</td>
</tr>
<tr>
<td colspan="2" height="1" bgcolor="006600"></td>
</tr>
</table>
<table width="740" border="0" cellspacing="0" cellpadding="0" height="50" align="center">
<tr>
<td> </td>
</tr>
</table>
<br>
<table width="640" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td colspan="2"> <span class="green">共有</span><span class="red">【<%=rs.recordcount%>】</span><span class="green">條記錄滿足查詢條件!</span> <span class="green">計</span><span class="red">【<%=pagenum+1%>】<span class="green">頁,當前為第</span>【<%=currentpage%>】</span><span class="green">頁!</span></td>
</tr>
<tr>
<td colspan="2" height="1" bgcolor="006600"></td>
</tr>
<%
rs.AbsolutePage= currentPage
rowCount = 1
'response.write(sqlstr)
While not rs.EOF and rowCount <=mPAGESIZE
%>
<tr>
<td width="288"><span class="green">【 品名 】</span><%=rs("pname")%></td>
<td width="352"><span class="green">【供求類型】</span><%=rs("itype")%></td>
</tr>
<tr>
<td width="288"><span class="green">【 價格 】</span><%=rs("price")%></td>
<td width="352"><span class="green">【所在城市】</span><%=rs("city")%></td>
</tr>
<tr>
<td colspan="2">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="12%" valign="middle" class="green">【聯系地址】</td>
<td width="88%"><%=rs("contact")%></td>
</tr>
<tr>
<td width="12%" valign="middle" class="green">【物品描述】</td>
<td width="88%" bgcolor="#F4F4FF"><span class="red"><%=rs("desc")%></span></td>
</tr>
</table>
</td>
</tr>
<tr> <%
if rtrim(rs("email"))="" then
response.write "<td colspan="&"2"&">發布時間:"&rs("stime")&"</td>"
else
%>
<td width="288"><span class="green">【E_mail 】</span><a href="mailto:<%=rs("email")%>"><%=rs("email")%></a></td>
<td width="352"><span class="green">【發布時間】</span><%=rs("stime")%></td>
<%end if%> </tr>
<tr>
<td colspan="2" height="1" bgcolor="006600"></td>
</tr>
<tr>
<td colspan="2" align="center"> <%rowCount = rowCount + 1
RS.MoveNext
Wend%> <%sqlstr=server.URLEncode(sqlstr)
for i = 1 to RS.PageCount%> <a href="pagequary.asp?currentPage=<%=i%>&sqlstr=<%=sqlstr%>"><%=i%></a>
<%next
pagenum=rs.PageCount%> </td>
</tr>
<tr>
<td colspan="2" align="right"> <%if pagenum<>0 then
if currentPage<pagenum then%> <a href="./pagequary.asp?currentpage=<%=(currentPage+1)%>&sqlstr=<%=sqlstr%>">下一頁</a>
<%
end if
if currentPage>1 then
%> <a href="./pagequary.asp?currentpage=<%=(currentPage-1)%>&sqlstr=<%=sqlstr%>">上一頁</a>
<%
end if
end if
%> <a href="./main.asp">返回</a> </td>
</tr>
</table>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -