<%
'-------------------------------- 取某表中纪录总数 -------------------------------------
Function Get_Count(Tablename)
Dim Rs_count,strQuery
strQuery = "select count(*) from " & Tablename
'Response.Write strQuery & "<br>"
Set Rs_count=Conn.Execute(strQuery)
Get_Count=Rs_count(0)
Rs_count.Close()
End Function
'------------------------- 输出当前页面的数据记录页数 ----------------------
Function Output_Pages(iCount,iCur,strURL)
Dim iTemp,i,j
iTemp=Int(iCur/10)
If iCount>10 and iTemp=(iCur/10) Then iTemp=iTemp-1
If iCount>0 Then
If iCount>10 and iCur>10 Then Response.Write ("<a href=" & strURL & (iTemp-1)*10+1 & ">" & "<<" & "</a> ")
For i=1 to 10
If iCur<>iTemp*10+i Then
Response.Write("<a href=" & strURL & iTemp*10+i & ">" & iTemp*10+i & "</a> ")
Else
Response.Write iCur & " "
End If
If iTemp*10+i=iCount Then Exit For
Next
If iCount>10 and iCount>(iTemp+1)*10 Then Response.Write (" " & "<a href=" & strURL & (iTemp+1)*10+1 & ">" & ">></a>")
Else
Response.Write "0"
End If
End Function
'------------------------- 定义当前页iCurPage值(附属于下一函数) ----------------------
Function Define_iCurPage(strPage,iCount)
If strPage="" Then
strPage=1
Else
strPage=CInt(strPage)
End IF
If strPage<=1 then strPage=1
If strPage>=icount then strPage=iCount
Define_iCurPage=strPage
End Function
'------------------------- 定义记录集的相关属性(翻页用) ----------------------
Function Define_RecordSet_Property(Rs_sql,iNum,iPage)
If Rs_sql.recordcount<>0 then
Rs_sql.PageSize=iNum
iPageCount=Rs_sql.pagecount
iCurpage=Define_iCurPage(iPage,iPageCount)
Rs_sql.Absolutepage=iCurpage
Else
iCurPage=0
iPageCount=0
End If
End Function
%>
<table border=0 cellPadding=2 cellSpacing=0 align=center>
<tr class=content valign = "top">
<%
if iCount > 0 then
dim iPageCount,iCurPage,iRow,iRec
iRec = 1
iRow = 5
strQuery = "select * from Room_Info where " & strWhere & " order by Room_Info_ID desc"
set Rs = server.CreateObject("ADODB.RECORDSET")
Rs.Open strQuery,Conn,3,1,1
Rs.CacheSize=iRow
Call Define_RecordSet_Property(Rs,iRow,request("txt_page"))
dim pageCount
if ((iCount/iRow)<>Int(iCount/iRow)) then
pagecount=Int(iCount/iRow+1)
else
pagecount=Int(iCount/iRow)
end if
%>
<td valign = "top" >
<table border="1" cellspacing="0" cellpadding="3" bordercolor="White">
<tr class=subtitle>
<td >客房种类</td>
<td>删除</td>
</tr>
<%
do while iRec<=iRow
if Rs.eof then exit do
%><tr class=content class=content <% if iRec mod 2 <> 0 then Response.Write "bgcolor=#E7E7D6" else Response.Write "bgcolor=#F3F4EC" end if%>>
<% irecnew=(request("txt_page")-1)*iRow
irecnew=irecnew+irec
%>
<td><%=irecnew%></td>
<td><%=Rs("Room_Type")%></td>
<%
'================= ProgrammName: 分页函数 =======================
Function cutPage(sqlStr,Conn,dateNums,pageNums,URLs)'利用ADO分页的函数
Dim sql,Cn,dateNum,pageNum,URL,rsDate
Sql=Trim(sqlStr) '获得sql语句。
Set Cn=Conn '获得数据对象
dateNum=Cint(dateNums) '获得每页得记录数
pageNum=Cint(pageNums) '获得当前页码
URL=Trim(URLs) '获得路径
Set rsDate=Server.CreateObject("ADODB.Recordset")
rsDate.PageSize=dateNum
rsDate.Open Sql,cn,1,1
IF rsDate.Eof Then
Response.Write("<center><font stlye='font-size:14px;' color='#ff0000'>对不起,没有记录!</font></center>")
Else
IF pageNum="" or pageNum<1 Then
pageNum=1
ElseIf pageNum>rsDate.PageCount Then
pageNum=rsDate.PageCount
End IF
rsDate.absolutepage =pageNum
Dim recordHead,recordLast '定义当前页开头记录和结束记录
recordHead=1
If pageNum>1 Then recordHead=dateNum*(pageNum-1)
If pageNum>=rsDate.PageCount Then
recordLast=rsDate.RecordCount
Else
recordLast=dateNum*pageNum
End If
Response.Write("<table width=100% border='0' cellpadding='0' cellspacing='0' style='font-size:12px;'>")
Response.Write("<tr><td height=38 align=left><font stly='font-size:12px;'>(第"&recordHead&"-"&recordLast&"条,共"&rsDate.Recordcount&"条,每页显示"&dateNum&"条)</font></td></tr>")
Dim URLa '定义判断输入得URL包含?没有的变量
Dim upPage,downPage,allPage '定义向上和向下翻的变量
Dim allWrite '定义输出
upPage=pageNum-1
downPage=pageNum+1
URLa=Split(URL,"?",-1,1)
If URLa(0)=URL Then
upPage="<a href=" & URL & "?page=" & upPage &" stlye='font-size:12px;'>上一页</a> "
If pageNum=1 Then upPage=""
downPage="<a href=" & URL & "?page=" & downPage &" stlye='font-size:12px;'>下一页</a>"
If pageNum=rsDate.PageCount Then downPage=""
Else
upPage="<a href=" & URL & "&page=" & upPage &" stlye='font-size:12px;'>上一页</a> "
If pageNum=1 Then upPage=""
downPage="<a href=" & URL & "&page=" & downPage &" stlye='font-size:12px;'>下一页</a>"
If pageNum=rsDate.PageCount Then downPage=""
End If
allWrite=upPage & downPage & " 共" & rsDate.PageCount & "页 " & "目前第"& pageNum &"页"
allwrite="<font style='font-size:12px;'>" & allWrite & " 到第<input type='text' style='width:30px;'>页<input type='submit' value='GO'></font>"
Response.Write("<tr><form name='formPage' method='post' action="&URL&"><td height=30 align=right style='font-szie=12px;'>" & allWrite & "</td></form></tr>")
Response.Write("<tr><td align=center>")
Response.Write("<table width=100% border='0' cellpadding='0' cellspacing='0'>")
Response.Write("<tr>")
Response.Write("<tr bgcolor='#efffce' height=25>")
Dim id,i
For i=0 to rsDate.Fields.Count-1 '设置表头
Response.Write("<td align='center'><font style='font-size:14px;'><b>"&rsDate.Fields(i).Name&"</b></font></td>")
Next
Response.Write("</tr>")
id=0
While not rsDate.EOF and id<dateNum
id=id+1
If id Mod 2=0 then
Response.Write("<tr bgcolor=#f7f6e7>")
Else
Response.Write("<tr bgcolor=#ffffff>")
End If
For Each fils in rsDate.Fields
Response.Write("<td align='center' height=20>"&fils&"</td>")
Next
Response.Write("</tr>")
rsDate.MoveNext
Wend
Response.Write("<tr height=30 bgcolor='#efffce'>")
For i=0 to rsDate.Fields.Count-1 '设置表尾
Response.Write("<td align='center'><font style='font-size:14px;'><b>"&rsDate.Fields(i).Name&"</b></font></td>")
Next
Response.Write("</tr>")
Response.Write("</table></td></tr>")
Response.Write("<tr><form name='formPage1' method='post' action="&URL&"><td height=30 align=right>" & allWrite & "</td></form></tr>")
End IF
rsDate.close
Set rsDate=nothing
End Function
%>
page=request("page")
sql="select * from [table]"
url="xx.asp"Call cutPage(sql,conn,"3",page,url)'3代表每页显示3条记录