Super ASP big paging

xiaoxiao2021-03-06  47

<%

'==================================================== ==================

'ShowMorePage ASP version

'Version Huangjm1.00

'Code by Maomao

'Create

Date 2004-09-28

'QQ: 5144707

'http://blog.9cbs.net/maomaoysq

'WRITE

For my lover: huangjm 'This program can be used free, modify, but please keep the above information

'

'

FUNCTION

'This program is mainly packaged by the part of the data paging, and the data display is completely customized by the user.

'Support URL multiple parameters: http://www.6*.com/***.asp? Aa = 1 & Page = 9 & bb = 2

'

'

'Paramers:

'PapGesize Definition Subject Number of Records of each page

'Getcurpagenum Returns the number of records for the current page This property is read-only

'Getrs returns this property read-only

'GetConn gets database connections

'GetSQL gets query statements

'Interface of

Class

'Showpage display paging navigation bar, unique common method

'

'############# 类 调 样 样 ######################

'Creating an object

'

Set hjmpage = new showmorepage

'Get database connections

'hjmpage.getconn = conn

'SQL statement

'hjmpage.getsql = "

Select * from shop_books where newsbook = 1 Order by Bookid DESC "

'Setting the record strip data for each page is 20, and 10 items are displayed by default.

'hjmpage.pagesize = 20

'Display paging information, you can call any position, you can call multiple times

'hjmpage.showpage ()

'

SET RS = hjmpage.getrs () 'Returns Recordset

'Show data start

'Here you can customize the display mode.

'

For i = 1

TO HJMPAGE.GETCURPAGENUM 'The number of records of the current page

'

Response.write

LEFT (

TRIM (RS ("BookName"), 13) & "..."

'rs.movenext

'

NEXT

'Show data end

'

SET HJMPAGE =

Nothing

'############# 类 调 样 样 ######################

'==================================================== ================== const btn_first = " 9 "Defines the first page button display style

Const btn_prev = " 3 "Define Previous Page button Display Style

Const btn_next = " 4 "Defines the next button display style

Const btn_last = ": "Defines the last page button display style

Const xd_align = "center" "Defines the page information alignment

Const xd_width = "100%" defines the size of the page information box

Class showmorepage

Private Obj_conn, Obj_RS, STR_SQL, INT_PAGESIZE, STR_ERRORS, INT_CURPAGE, STR_URL, INT_TOTALPAGE, INT_TOTALRECORD

'==================================================== ================

'PageSize properties

'Set the page size of each page

'==================================================== ================

Public

Property

Let Pagesize (intValue) IF

ISNUMERIC (INTVALUE)

THEN

INT_PAGESIZE =

CLNG (intValue)

Else

STR_ERRORS = STR_ERRORS & "PageSize is incorrect"

Showerror ()

End

IF

End

Property

Public

Property

Get PageSize

IF int_pageSize = "" "

OR (

NOT

IsNumeric (int_pagesize))))))

THEN

PageSize = 10

Else

Pagesize = int_pageSize

End

IF

End

Property

'==================================================== ================

'Getrs attribute

'Returning the record set after paging

'==================================================== ================

Public

Property

Get getrs ()

IF INT_TOTALRECORD = 0

THEN

Call getpage ()

IF

Not (Obj_rs.eof

And Obj_rs.bof)

THEN

IF INT_CURPAGE <> 1

THEN

IF int_curbage-1

THEN

Obj_rs.move (int_curbage-1) * Pagesize

DIM Bookmark

Bookmark = Obj_rs.bookmark

Else

INT_CURPAGE = 1

end

IF

end

IF

End

IF

Set getrs = OBJ_RS

End

Property

'==================================================== ================= GetCurpagenum attribute

'Return to the current page record number

'==================================================== ================

Public

Property

Get getcurpagenum ()

DIM INT_PAGENUM

INT_PAGENUM = INT_PAGESIZE

IF INT_TOTALRECORD = 0

THEN

Call getpage ()

IF INT_CURPAGE> INT_TOTALPAGE

THEN

INT_CURPAGE = INT_TOTALPAGE

INT_PAGENUM = INT_TOTALRECORD- (int_totalpage-1) * int_pageSize

Elseif Int_Curpage = INT_TOTALPAGE

THEN

INT_PAGENUM = INT_TOTALRECORD- (int_totalpage-1) * int_pageSize

End

IF

GetCurpagenum = INT_PAGENUM

End

Property

'==================================================== ================

'GetConn gets database connections

'

'==================================================== =============== p PUBLIC

Property

Let getConn (Sconn)

Set obj_conn = sconn

End

Property

'==================================================== ================

'GetSQL gets query statements

'

'==================================================== ================

Public

Property

Let GetSQL (Svalue)

STR_SQL = Svalue

End

Property

'==================================================== ==================

Initialization of 'Class_Initialize class

'Initialize the current page

'

'==================================================== ================== Private

SUB Class_initialize

'==========================

'Set some parameters 黙 recognition

'==========================

INT_PAGESIZE = 10 'Set the default value of the paging is 10

INT_TOTALRECORD = 0

'==========================

'Get the front value

'==========================

IF Request ("Page") = ""

THEN

INT_CURPAGE = 1

Elseif

NOT

ISNUMERIC (Request ("Page")))))

THEN

INT_CURPAGE = 1

Elseif

Cint

Trim (Request ("Page"))) <1

THEN

INT_CURPAGE = 1

Else

INT_CURPAGE =

Cint

Trim (Request ("Page")))))

End

IF

End

Sub

'==================================================== ===================

'OpenRS opens the data set

'There are home, previous page, next page, last page, and digital navigation

'

'==================================================== ==================== Private

SUB OpenRS ()

SET OBJ_RS = Server.

CreateObject ("AdoDb.Recordset")

Obj_rs.open str_sql, obj_conn, 1, 1

End

Sub

'==================================================== ===================

'getPage creates a paging navigation bar

'There are home, previous page, next page, last page, and digital navigation

'

'==================================================== ===================

Private

SUB getPage ()

IF

TypeName (OBJ_RS) <> "Object"

THEN

Call OpenRS ()

INT_TOTALRECORD = OBJ_RS.Recordcount

IF INT_TOTALRECORD <= 0

THEN

STR_ERRORS = STR_ERRORS & "The total number of records is zero, please enter the data"

Call showerror ()

End

IF

IF INT_TOTALRECORD

MOD PAGESIZE = 0

THEN

INT_TOTALPAGE = INT_TOTALRECORD / INT_PAGESIZE

Else

INT_TOTALPAGE = INT_TOTALRECORD / INT_PAGESIZE 1

End

IF

IF INT_CURPAGE> INT_TOTALPAGE

THEN

INT_CURPAGE = INT_TOTALPAGE

End

IF

End

Sub

'==================================================== ==================== ShowPage creates a paging navigation bar

'There are home, previous page, next page, last page, and digital navigation

'

'==================================================== ===================

Public

SUB ShowPage ()

DIM STR_TMP

Str_url = getURL ()

IF INT_TOTALRECORD = 0

THEN

Call getpage ()

'==================================================== ==================

'Display paging information, each module changes the location according to yourself

'==================================================== ==================

Response.write ""

STR_TMP = ShowFirstPRV

Response.write str_TMP

STR_TMP = Shownumbtn

Response.write str_TMP

STR_TMP = Shownextlast

Response.write str_TMP

STR_TMP = showpageInforesponse.write str_tmp

Response.write ""

End

Sub

'==================================================== ===================

'ShowFirstPRV Show Home, Previous Page

'

'

'==================================================== ===================

Private

Function showfirstprv ()

DIM STR_TMP, INT_PRVPAGE

IF int_curbage = 1

THEN

STR_TMP = BTN_First & "& btn_prev

Else

INT_PRVPAGE = INT_CURPAGE-1

STR_TMP = " "& btn_first & """>" & btn_first & "

CSTR (int_prvpage) & ""> "& btn_prev &" "

End

IF

ShowfirstPRV = STR_TMP

End

FUNCTION

'==================================================== ===================

'ShowNextlast Next, Last Page

'

'

'==================================================== ==================== Private

Function shownextlast ()

DIM STR_TMP, INT_NEXTPAGE

IF INT_CURPAGE> = INT_TOTALPAGE

THEN

STR_TMP = BTN_NEXT & "& BTN_LAST

Else

INT_NEXTPAGE = INT_CURPAGE 1

STR_TMP = "

CSTR (int_nextpage) & ""> "& btn_next &"

CSTR (int_totalpage) & ""> "& btn_last &" "

End

IF

Shownextlast = STR_TMP

End

FUNCTION

'==================================================== ===================

'ShownumbTN Digital Navigation

'Display 10 pages each time

'

'==================================================== ===================

Private

Function shownumbtn ()

DIM I, STR_TMP, M, N

m = int_curbage - 4

n = int_totalpage

IF n> 1

THEN

For i = 1to 10

IF m <1

Then M = 1

IF m> n

THEN

exit

for

end

IF

STR_TMP = STR_TMP & "[

CSTR (I) & ""> "& I &" ] "

m = m 1

NEXT

end

IF

Shownumbtn = str_tmp

End

FUNCTION

'==================================================== ===================

'ShowPageInfo Pipe Information

'It is more important to modify itself.

'

'==================================================== ===================

Private

Function showpageInfo ()

DIM STR_TMP

Str_TMP = "Page:" & INT_CURPAGE & "Page Total" & INT_TOTALRECORD & "Record" & INT_PAGESIZE & "Bar / Each page"

ShowpageInfo = STR_TMP

End

FUNCTION

'==================================================== ==================

'GetURL gets the current URL

'Different by the URL parameters, get different results

'

'==================================================== ================== Private

Function getURL ()

DIM STRURL, TMP_URL, I, J, Search_Str, Result_URL

Search_str = "Page ="

Strurl = Request.serverVariables ("URL")

Strurl =

Split (Strurl, "/")

i =

Ubound (Strurl, 1)

TMP_URL = Strurl (i) 'gets the current page file name

Str_params =

Trim (Request.SerVariables ("query_string")))

If str_params = "" "

THEN

Result_url = TMP_URL & "? Page ="

Else

IF

INSTRREV (STR_PARAMS, Search_Str) = 0

THEN

Result_url = tmp_url & "?" & str_params & "& page ="

Else

j =

Instrrev (Str_Params, Search_Str) -2

IF j = -1

THEN

Result_url = TMP_URL & "? Page ="

Else

STR_LPARAMS =

LEFT (STR_PARAMS, J)

STR_RPARAMS =

Right (Str_Params,

Len (str_params) -J-1)

IF

INSTR (STR_RPARAMS, "&") <> 0

THEN

STR_RPARAMS =

Right (str_rparams,

Len (str_rparams) -

INSTR (STR_RPARAMS, "&") 1)

Else

Str_rparams = ""

end

IF

Result_url = TMP_URL & "?" & str_lparams & str_rparams & "& page ="

End

IF

End

IF

End

IF

GetURL = Result_URL

End

FUNCTION

'==================================================== =================== 'Sets the Terminate event.

'

'==================================================== ===================

Private

SUB Class_Terminate

OBJ_RS.CLOSE

SET OBJ_RS =

Nothing

Obj_conn.close

SET OBJ_CONN =

Nothing

End

Sub

'==================================================== ===================

'ShowError error prompt

'

'

'==================================================== ===================

Private

SUB ShowError ()

IF str_errors <> ""

THEN

Response.write ("" & str_errors & ")

RESPONSE.

End

End

IF

End

Sub

End

Class%>

Function.asp "->

<%

DIM Conn

Call dbconnect ()

'############# 类 调 样 样 ######################

'Creating an object

Set hjmpage = new showmorepage

'Get database connections

hjmpage.getconn = conn

'SQL statement

hjmpage.getsql = "

SELECT TOP 6 * from shop_books where newsbook = 1 Order by Bookid DESC "

'Setting the record strip data for each page is 5

HJMPage.pageSize = 2

SET RS = hjmpage.getrs () 'Returns Recordset

'Show paging information, this method can be

After set RS = hjmpage.getrs (), you can call multiple times in any position.

hjmpage.showpage ()

'Display Data

Response.write ("<")

For i = 1

TO HJMPAGE.GETCURPAGENUM 'The number of records of the current page

'Here you can customize the display mode.

%>

转载请注明原文地址:https://www.9cbs.com/read-80736.html

New Post(0)