Easy thinkphp Two-level linkage

Source: Internet
Author: User
Simple thinkphp two-level linkage

On the Internet to read a lot about the thinkphp two-level linkage of the article, but I personally feel that the writing is not very simple, some cumbersome, below is a simple two-level linkage I write. I am a novice master can not look down.

HTML file:

Liandong.html

The first step is to introduce the Jquery.js file

Second-level linkage


Please select game area //Cycle Show parent class foreach ($plei as $val) {?>{$val [type_name]} }?>

Please select a game suit


PHP file

IndexAction.class.php

Class Indexaction extends Action {

Public Function Liandong () {

Instantiating a data table

$type =m (' type ');

The first is the parent class in the Query category table, and my parent's PID is 0.

$plei = $type->where (' pid=0 ')->select ();

assigning variables

$this->assign ("Plei", $plei);

This is important to judge whether the contents of the parent class are changed (PS: I will not write this judgment, always error, very headache)

if ($_get[id]) {

$sel = $type->where (' pid= '. $_get[id])->select ();

$this->ajaxreturn ($sel, ' subclass ', 1);

}

$this->display ();

}

}

This is my category table database.

This is my project to use the two-level linkage of the place, the code to write this is not my copy and paste, there may be subtitles or punctuation wrong place, please read carefully

If you have any questions, please leave me a message.

  • 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.