Method One:
1 Public functionshow_cate () {2 3 $category _name=Array(4' 1 ' and ' the forefront of political and legal governance ',5' 2 ' = ' policies and regulations ',6' 3 ' = ' Peace building ',7' 4 ' = ' notification announcement ',8' 5 ' = ' theory discussion ',9' 6 ' = ' local dynamics ',Ten' 7 ' = ' Team building ', One ); A $category _id= I (' get.category_id '); - $model= M (' zx_article '); - //calculate the total number of data bars to display the $count=$model->where (' category_id = '.$category _id)->order (' article_id desc ')Count(); - //instantiate the page class, passing in the total number of bars and the number of bars to display per page - $page=New\think\page ($count, 2); - //use the Limit function to specify the number of queries and actions + $data=$model->where (' category_id = '.$category _id)->order (' article_id desc ')->limit ($page->firstrow. ', '.$page->listrows)Select (); - //Pass data to template + $this->assign (' Data ',$data); A //Call the show () function of the page class
at $this->assign (' page ',$page-Show ()); - $this->assign (' name ',$category _name[$category _id]); - $this-display (); -}
thinkphp Implementing Data Paging