ASP page display of the random cover

Source: Internet
Author: User
Pagination | Shows the first time you write this post:
Personally think that the function is good, completely self-creation, no plagiarism, if there are similarities, pure coincidence!
Description
. pagesize ' defines the number of records to display per page
. RecordCount ' Total records
. PageCount ' Total pages
. AbsolutePage ' current page number (page)
Index.asp didn't join any layout design, so it was a bit messy. Function I also did not test, theoretically can be achieved (except I hit the wrong key). ......
The Index.asp sample program is as follows:

<% @LANGUAGE = "VBSCRIPT" codepage= "936"%>
<%
Option Explicit ' forces a requirement to define a variable
' On Error Resume Next

Dim page Defines page number variables
Page=request.querystring ("page") ' Get Address bar page number
If IsNumeric (page) Then ' page number is an integer
Page=cint (page)
If Page<1 then page=1
Else
Page=1
End If

Dim strSQL ' defines SQL statements
' Mtest table name
' File1 field (This example shows a field, which is typically more than one field)
Strsql= "Select File1 from Mtest"

Dim Objconn,strconn,objrs
Set Objconn=server. CreateObject ("Adodb.connection")
strconn= "Driver={microsoft Access DRIVER (*.mdb)}; dbq= "& Server. MapPath ("Db.mdb")
objConn.Open strconn
Set Objrs=server. CreateObject ("Adodb.recordset")
Objrs.open strSQL, objconn, 1,1

Records in the If objrs.eof or objrs.bof then ' table
' The following paragraph is a timely shutdown and release of resources
Objrs.close
Set objrs=nothing
Objconn.close
Set objconn=nothing
Response.Write "No Data"
Else
Objrs.pagesize=20 ' A page shows the number of records
Dim Intrecun,intpacun
Intrecun=objrs.recordcount ' Total record number
Intpacun=objrs.pagecount ' Total pages
If Page>intpacun then Page=intpacun ' current page number compared to total pages
Objrs.absolutepage=page

Response.Write "Total: &intReCun&" page is currently: &intPaCun& page
Dim strfile1,i
Set Strfile1=objrs ("File1") ' Creates an object (in this case, a field that is actually more than one field)
I=1
' The object should be used here
The number of i<=20 ' at this time is 20 of the records that are displayed on a objrs.eof objrs.pagesize
Response.Write (StrFile1 & "<br>")
I=i+1
Objrs.movenext ' Move down one
Loop
' The following paragraph is a timely shutdown and release of resources
Objrs.close
Set objrs=nothing
Objconn.close
Set objconn=nothing
Set strfile1=nothing
%>

<table>
<form action= "index.asp" method= "Get" name= "Posttopic" >
<tr>
&LT;TD height= "align=" center "> <a href=" index.asp "> First page </a>
<a href= "index.asp?page=<%=page-1%>" > Prev </a>
<input name= "page" type= "text" id= "page" value= "<%=page%>" size= "6" maxlength= "4" >

<input name=cmdconfrom type=submit id= "Cmdconfrom" value= submit >
<a href= "index.asp?page=<%=page+1%>" > next page </a> <a href= "index.asp?page=<%=intpacun%>" > Last page </a>
</td>
</tr>
</form>
</table>
<%
End If
%>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.