Imitating ASP pages written by PHP

Source: Internet
Author: User
<%
'Paging program
'Total_records total number of records
'Everypage_records: Number of Entries displayed per page
'Current_page current page number
'URL: the url to be passed. The variable to be passed can be contained here, for example, "list. asp? "Or" list. asp? Keyword = key &"
'The program call is relatively simple, but it is still more troublesome than PHP. Continue to work hard.
Sub show_page (total_records, everypage_records, current_page, url)
If IsNumeric (total_records) then
Total_records = Int (total_records)
Else
Total_records = 0
End if

If IsNumeric (everypage_records) then
Everypage_records = Int (everypage_records)
If everypage_records <= 0 then
Everypage_records = 10
End if
Else
Everypage_records = 10
End if

If IsNumeric (current_page) then
Current_page = Int (current_page)
Else
Current_page = 1
End if

'The total number of pages, that is, the last page
If total_records mod everypage_records = 0 then
Last_page = Int (total_records/everypage_records)
Else
Last_page = Int (total_records/everypage_records) + 1
End if

'Determine whether current_page meets the criteria and attach the value to the page
If current_page> = last_page then
Page = last_page
Elseif current_page <= 1 then
Page = 1
Else
Page = current_page
End if

'Previous page
If page <= 0 then
Prepg = 0
Else
Prepg = page-1
End if
'Next page
If page = last_page then
Nextpg = 0
Else
Nextpg = page + 1
End if

'Start record on this page
Firstcount = prepg * everypage_records
'End record of this page
If nextpg> = 1 then
Lastcount = (nextpg-1) * everypage_records
Else
Lastcount = total_records
End if
'Start pagination navigation bar code
Pagenav = ""
Pagenav1 = ""
Pagenav = pagenav & "display the total number of <B>" & firstcount & "-" & lastcount & "</B> records <B>" & total_records & "</B> records"
Pagenav1 = pagenav1 & "display the total number of <B>" & firstcount & "-" & lastcount & "</B> records <B>" & total_records & "</B> records"
Related Article

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.