The column of our column can not always be a number to show it?? In that case, the boss will let you go straight to the pack. Oh, hehe ...
So we need to correlate the query to her, and the controller code looks like this:
Public functionlists () {//$mod = M ("article")->select (); $this-Assign (' mod ', $mod); $mod= M (' article '); $totalRows=$mod-Count(); //When a paging object is created, the total number of records and the number of page bars is required for the paging object $page=New\think\page ($totalRows, 2); $page-Rollpage = 5;//How many bars are displayed on the pagination list $page->setconfig (' theme ', '%first%%up_page%%link_page%%down_page%%end%%header% '); $page->setconfig (' first ', ' home '); $page->setconfig (' prev ', ' prev '); $page->setconfig (' Next ', ' next page ')); $page->setconfig (' Last ', ' End '); $pageHtml=$pageShow ();//the connection of the raw page (the HTML Code of the page bar) $thisAssign (' pagehtml ',$pageHtml);//assign a page bar to a template//2. Querying list data for the current page $amod=$modTable ("Jj_category cate,jj_article Art") ->where ("Cate.cate_id=art.ar_cateid") ->field (' cate.cate_name,art.* ')page (I (' GET.P ', 1),$page->listrows)Select (); $thisAssign (' Amod ',$amod); //dump ($amod); $this-display (); }
Then in the foreground direct variables can be:
The final effect is as follows:
Life Lei Dog thinkphp project----Enterprise website 16 article List page Perfect (association query)