分頁和查詢衝突?
請幫小弟看看原代碼,還是不會,謝謝先
<%@ Language=VBScript %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>
<% emp=request("工號")
emp=ucase(emp)
%>
<%
Set Conne = Server.CreateObject("ADODB.Connection")
conne.open "Driver={Microsoft ODBC For Oracle};server=dnisfis; uid=sfis; pwd=sfis"
Set RS=Server.CreateObject("ADODB.RecordSet")
if (emp = "") then
sql= "select C.EMP,P.EMP_PASS,C.FUN,C.PRIVILEGE,C.PRG_NAME,P.EMP_NAME FROM SFIS1.C_PRIVILEGE C, SFIS1.C_EMP_DESC_T P WHERE C.EMP=P.EMP_NO order by C.EMP desc"
else
sql="select C.EMP,P.EMP_PASS,C.FUN,C.PRIVILEGE,C.PRG_NAME,P.EMP_NAME FROM SFIS1.C_PRIVILEGE C,SFIS1.C_EMP_DESC_T P where C.EMP='"&emp&"' AND P.EMP_NO=C.EMP "
end if
rs.open sql, conne, 3,3
%>
<%
dim maxpages
dim totalrecord
dim TotalPages
if not isempty(Request.QueryString("page")) then
thepage=cint(Request.QueryString("page"))
else
thepage=1
end if %>
<%
%>
<% if not rs.eof then '在最後結束
rs.PageSize=20
totalrecord=rs.RecordCount
' totalrecord=int(rs(0))
totalpages=rs.pagecount
maxpages=rs.pagesize
if thepage>totalpages or thepage<=0 then
thepage=1
showContent
else
rs.absolutepage=thepage
showContent
end if
rs.close
set rs=nothing
conne.close
set conne=nothing
%>
<%sub showContent%>
<% dim i
i=1 %>
<body>
<table border=0 width=100% bordercolor=#f1fce4 cellspacing=1 bgcolor=#bdf084 align=left style="table-layout:fixed" >
<TR bgcolor=#f1fce4 align=middle>
<TD bgcolor=#bdf084 width=10%><P align=center><FONT size=3>序號</FONT></P></TD>
<TD bgcolor=#bdf084 width=13%><P align=center><FONT size=3>工號</FONT></P></TD>
<TD bgcolor=#bdf084 width=13%><P align=center><FONT size=3>姓名</FONT></P></TD>
<TD bgcolor=#bdf084 width=13%><P align=center><FONT size=3>密碼</FONT></P></TD>
<TD bgcolor=#bdf084 width=23%><P align=center><FONT size=3>功能</FONT></P></TD>
<TD bgcolor=#bdf084 width=10%><P align=center><FONT size=3 >權限</FONT></P></TD>
<TD bgcolor=#bdf084><P align=center><FONT size=3 >站別</FONT></P></TD></tr>
<%
do while not rs.eof
%>
<tr bgcolor=#f1fce4>
<TD borderColor=#9400d3 width=90> <P align=center><FONT size=2><%=i %></FONT></P></TD>
<TD borderColor=#9400d3 width=90> <P align=center><FONT size=2><%=RS("EMP") %></FONT></P></TD>
<TD borderColor=#9400d3 width=90> <P align=center><FONT size=2><%=RS("EMP_NAME") %></FONT></P></TD>
<TD borderColor=#9400d3 width=60> <P align=center><FONT size=2><%=rs("EMP_PASS")%></FONT></P></TD>
<TD borderColor=#9400d3 width=160> <P align=center><FONT size=2><%=rs("FUN")%></FONT></P></TD>
<TD borderColor=#9400d3 width=90> <P align=center><FONT size=2><%=rs("PRIVILEGE")%></FONT></P></TD>
<TD borderColor=#9400d3 width=90> <P align=center><FONT size=2><%=rs("PRG_NAME")%></FONT></P></TD>
<% i=i+1
if i>=maxpages then%>
<% exit do%>
<%end if%></TR>
<% rs.movenext%>
<% loop%>
<% If thepage>=1 Then %>
<% showpages '顯示分頁情況 %>
<%end if%>
<% end sub%>
<%
else
response.write "<font size='4' color='#000000'>現在沒有內容。</font>"
rs.close
set rs=nothing
conne.close
set conne=nothing
end if
%>
<%
Sub showpages
if thepage=1 then
Response.Write "【首頁】"
Response.Write "【上一頁】"
else %>
<%
Response.Write "<A href=shopfind.asp>【首頁】</A>"
Response.Write "<A href=?Page=" & (thepage-1) &">【上一頁】</A>"%>
<% end if
if totalpages-thepage<1 then
Response.Write "【下一頁】"
Response.Write "【尾頁】"
else %>
<% Response.Write "<A href=shopfind.asp?Page=" & (thepage+1) &">【下一頁】</A>"
Response.Write "<A href=shopfind.asp?Page=" & totalPages &">【尾頁】</A>" %>
<%end if%>
<% Response.Write "【第<font color=#000000>" & thepage & "</font>頁】"
Response.Write "【共<font color=#000000> "&totalpages&" </font>頁】"
Response.Write "【共<font color=#ff0000>" & totalrecord & "</font>條記錄】"
End Sub
%>
</table>
</html>