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.