Phpsqlite page.

Source: Internet
Author: User
Phpsqlite page. Operations on database files use the previous operation class. Refer to the previous article. I am very bad at literary talent, not to mention nonsense, directly go to the code:

 
 Table_name = ''; $ this-> tj =''; $ this-> page_size = ''; $ this-> current_page = ''; $ this-> total_page = ''; include_once 'sqlite _ db. php '; $ this-> db = new SqliteDB (); // you can call this operation method} function entrance ($ table_name, $ page_size, $ tj = '') // The limit page_size is not included in the SQL statement and is the number of entries displayed per page. {// Obtain the current page first. // SQL = "select * from tab where" + condition + "order by" + sorting + "limit" + how many records are displayed + "offset" + how many records are skipped; $ this-> page_size = $ page_size; $ this-> table_name = $ table_name; $ This-> tj = $ tj; $ this-> total_page = ceil ($ this-> db-> total ($ this-> table_name, $ this-> tj) /$ this-> page_size); if (! Isset ($ _ GET ['Page']) {$ this-> current_page = 1; // if no page exists, set to the first page by default} else {$ this-> current_page =$ _ GET ['Page'];} if ($ this-> current_page> $ this-> total_page) {// when the current page number is greater than the total page number, set the current page number to the total page number $ this-> current_page = $ this-> total_page ;} if ($ this-> current_page <1) {// when the current page number is greater than the total page number, set the current page number to the total page number $ this-> current_page = 1 ;} $ tj = $ this-> tj. 'limit '. $ this-> page_size. 'Offset '. ($ this-> current_page-1) * $ this-> page_size; $ result = $ this-> db-> Query ($ this-> table_name, $ tj); return $ result;} function page_bar () {$ old_url = $ _ SERVER ["REQUEST_URI"]; $ check = strpos ($ old_url ,'? '); $ Pre_urls = 'test'; if ($ check) {// if there is? If (substr ($ old_url, $ check + 1) = '') {// There is a question mark, but it is not followed by any parameter $ first_urls = $ old_url. 'page = 1'; // homepage $ pre_urls = $ old_url. 'page = '. ($ this-> current_page-1); // Previous Page; $ next_urls = $ old_url. 'page = '. ($ this-> current_page + 1); // Next Page; $ end_urls = $ old_url. 'page = '. $ this-> total_page; // Last page} else {// with question mark and parameter if (isset ($ _ GET ['Page']) {// if the parameter contains the page parameter, unset ($ _ GET ['Page']) is deregistered; $ old_url = 'http ://'. $ _ SERVER ['http _ host']. $ _ SERVER ['php _ SE LF '].'? '. Http_build_query ($ _ GET);} $ first_urls = $ old_url. '& page = 1'; // homepage $ pre_urls = $ old_url. '& page = '. ($ this-> current_page-1); // Previous Page; $ next_urls = $ old_url. '& page = '. ($ this-> current_page + 1); // Next Page; $ end_urls = $ old_url. '& page = '. $ this-> total_page; // last page} else {// if there is no question mark (that is, there is no parameter next to it, follow it directly) $ first_urls = $ old_url. '? Page = 1'; $ first_urls = $ old_url .'? Page = 1'; // homepage $ pre_urls = $ old_url .'? Page = '. ($ this-> current_page-1); // Previous page; $ next_urls = $ old_url .'? Page = '. ($ this-> current_page + 1); // Next page; $ end_urls = $ old_url .'? Page = '. $ this-> total_page; // Last page} // echo $ this-> table_name. 'Table _ name'; return'

[Total '. $ this-> total_page.' page, '. $ this-> current_page.' page] homepage previous page Last Page

';} Public function get_total_page () {return ceil ($ this-> total_record/$ this-> page_size) ;}// $ page = new PrePage (); // $ res = $ page-> entrance ('log', 10); // echo" "; // Foreach ($ res as $ key => $ row) {// echo $ row ['urls'].'
'; //} // Echo $ page-> page_bar ();?>

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.