Asp paging functions

Source: Internet
Author: User
 

Write your own paging function. Let's take a look.

// Create SQL part
Function makesql (keyword, page, sidk, bigleibiek)
// Keyword search, page pages, sidk sub-classes, bigleibiek categories
Dim keywordlist, I, SQL
If keyword <> "" then
Keywordlist = split (keyword)
For I = 0 to ubound (keywordlist)
Keywordlist (I) = trim (keywordlist (I ))
SQL = SQL & "(namek like '%" & keywordlist (I) & "%' or dizik like '%" & keywordlist (I) & "% 'or tesek like' %" & keywordlist (I) & "% ') and"
Next
End if
If (page = "" or page <1) then page = 1
If sidk <> "" then SQL = SQL & "leibiek =" & sidk & "and"
If page = 1 then
SQL = "select top 8 idk, pick, namek, dizik, tesek, dianhuak, dianjik, pinlunk from shop where "& SQL &" bigleibiek = "& bigleibiek &" order by idk desc"
Else
SQL = "select top 8 idk, pick, namek, dizik, tesek, dianhuak, dianjik, pinlunk from shop where idk <(select min (idk) from (select top "& 8 * (page-1) &" idk from shop where "& SQL &" bigleibiek = "& bigleibiek &" order by idk desc )) and "& SQL &" bigleibiek = "& bigleibiek &" order by idk desc"
End if
Makesql = SQL
End Function

// Obtain the record set and the number of record sets in the middle and disable rs.
//

// Manufacturing the top and bottom pages
// Sidk small class, keyword search, current page number, rscount qualified records
Sub pages (sidk, keyword, page, rscount)
Dim pages_sort, jj, pages_keyword, kk, pages_page1, pages_page2
If trim (sidk) <> "" then
Pages_sort = "sort =" & sidk
Jj = "&"
End if
If trim (keyword) <> "" then
Pages_keyword = jj & "keyword =" & keyword
Kk = "&"
End if
Kk = left (jj & kk, 1)
If trim (page) = "" then page = 1
If trim (page) <> "then
If page <2 then
Pages_page1 = ""
Pages_page2 = kk & "page = 2"
Else
Pages_page1 = kk & "page =" & (page-1)
Pages_page2 = kk & "page =" & (page + 1)
End if
End if
If rscount <8 then pages_page2 = "& page =" & page
Response. Write ("<div id = 'page'> <form name = 'page' method = 'get'> <a title = 'homepage 'href = 'index. asp? "& Pages_sort & pages_keyword &" '> homepage </a> <a title = 'previous page 'href = 'index. asp? "& Pages_sort & pages_keyword & pages_page1 &" '> Previous page </a> "& page &" <a title = 'next page 'href = 'index. asp? "& Pages_sort & pages_keyword & pages_page2 &" '> Next page </a> <input type = 'text' name = 'page' value =' "& page &" 'Id =' page _ size '/> <input type = 'ddy' value =' "& keyword &" 'name = 'keyword'/> <input type = 'ddy' value = '" & sidk & "'name = 'sort '/> <input type = 'submit' value = 'Jump '/> </form> </div> ")
End sub

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.