Pagination | control | In the previous article, we analyzed a simple common paging code control.
But usually we use the query function in the paging ASP page, so how to "encapsulate" the query?
The Include method is also required.
We can think of the query as two parts,
1, input, that is, to receive the user input query string, we put it in the Query.inc
2, output, that is, according to the user input content constructs the query condition, we put it in the Query_result.inc
In this way, our thinking is very clear,
1, put the query_result.inc before the SQL statement, construct the query criteria, and then embed the query criteria in the SQL statement
2, place the query.inc on the ASP page (usually the same line as Navigator.inc).
In the next article, it's a little bit more complicated, so let's take a look at a demo database: MyTest
Table 1 tbluserinfo ' User Information table
Field flduserinfo_id ' User ID
Flduserinfo_username
Flduserinfo_nickname
Flduserinfo_password
Table 2 Tbladdressbook ' Address Book list
Field fldaddressbook_id
Fldaddressbook_classid ' category ID
Fldaddressbook_userid ' User ID
Fldaddressbook_nickname
Table 3 Tbladdressbook_class ' Address Book category table
Field fldaddressbook_class_id ' Category ID
Fldaddressbook_class_title ' For example: friends, customers, relatives, netizens
Fldaddressbook_class_explain ' category description
View Vwaddressbook
SELECT Tbladdressbook_class.fldaddressbook_class_title,
Tbladdressbook_class.fldaddressbook_class_explain,
tbladdressbook.fldaddressbook_id, Tbladdressbook.fldaddressbook_userid,
Tbladdressbook.fldaddressbook_classid, Tbladdressbook.fldaddressbook_nickname,
From Tbladdressbook INNER JOIN
Tbladdressbook_class on
Tbladdressbook.fldaddressbook_classid = tbladdressbook_class.fldaddressbook_class_id
[Note: I added the name of the table to each field, which is convenient for generating views and other hidden hassles.] After my long attempt, I found this method really good. Therefore, we recommend this method of naming. ]
When we query in Tbladdressbook, we use Flduserid to differentiate each user's address book content, so add the "flduserid=" & Session ("UserID") restrictions. Now we add this restriction to our SQL statement.
Please see sample2.asp
< a > ASP files that require paging
Sample2.asp
<%
' Get the full path of the current ASP page, the important skill
Thescript = Request.ServerVariables ("Script_name")
Myconnstr = "Driver={sql server};server=yourserver;uid=sa;pwd=;d atabase=mytest"
Thepagesize = 20 ' number of records displayed per page
'//////////////////////////////////////////////////////////
'
' Define table name
'
'//////////////////////////////////////////////////////////
Thetablename= "AddressBook"
'///////////////////////////