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