Life Lei Dog thinkphp project----Enterprise website 16 article List page Perfect (association query)

Source: Internet
Author: User

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)

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.