tp5+jquery pagination with Template page substitution

Source: Internet
Author: User

Methods of PHP pages

//jquery Paging     Public functionJqpage () {//Receive current page        $p= Request::instance ()->param (' page '); $page=Empty($p)? 1:$p; //find the total number of bars        $count= db::table (' user ')Count(); //set the number of bars to display per page        $length= 3; //Find out the total number of pages        $num _page=Ceil($count/$length); //Set Offset        $limit= ($page-1) *$length; //Enquiry        $data= db::table (' user ')->limit ($limit,$length),Select (); //judging the current page stitching array        $arr[' data '] =$data; $arr[' home_page '] = 1;//Home Page        $arr[' prev_page '] =$page-1<=1? 1:$page-1;//Previous Page        $arr[' next_page '] =$page+1>=$num _page?$num _page:$page+1;//Next Page        $arr[' last_page '] =$num _page; returnView (' Jqpage ', [' list ' = =$arr],[' __css__ ' = '/static ', ' __js__ ' = '/static ']); }

HTML page

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <Metaname= "Viewport"content= "Width=device-width, User-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">    <Metahttp-equiv= "X-ua-compatible"content= "Ie=edge">    <Linkrel= "stylesheet"href= "__css__/css/bootstrap.css">    <title>JQ Paging</title></Head><Body><Tableclass= "Table table-bordered">    <TR>        <th>Id</th>        <th>User name</th>        <th>Password</th>        <th>Address</th>        <th>Cell phone</th>        <th>Operation</th>    </TR>{volist name= "list.data" id= "Vo"}<TR>        <TD>{$vo. ID}</TD>        <TD>{$vo. uname}</TD>        <TD>{$vo. pwd}</TD>        <TD>{$vo. Area}</TD>        <TD>{$vo. Phone}</TD>        <TD>            <ahref= "{: URL (' login/deldata ')}?id={$vo. ID}">Delete</a>            <ahref= "{: URL (' login/updpage ')}?id={$vo. ID}">Modify</a>        </TD>    </TR>{/volist}</Table><inputtype= "hidden"name= "P"ID= "P"value= "1"><ahref= "javascript:void (0);"onclick= "page ({$list. Home_Page})">Home</a><ahref= "javascript:void (0);"onclick= "page ({$list. Prev_page})">Previous page</a><ahref= "javascript:void (0);"onclick= "page ({$list. Next_page})">Next page</a><ahref= "javascript:void (0);"onclick= "page ({$list. Last_page})">Last</a><Scriptsrc= "__js__/js/jquery.js"></Script><Script>    functionpage (obj) {$.get ("{: url (' login/jqpage ')}?page="+obj,function(data,status) {//Console.log ("Data: \ n" + data + "\ n State:" + status);                $("Body"). HTML (data);    }); }</Script></Body></HTML>

tp5+jquery pagination with Template page substitution

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.