BiaodanController.class.php Controller Page
<?phpnamespace Admin\controller; UseThink\controller;classBiaodancontrollerextendscontroller{ Public functionZhuyemian () {$n= D ("Nation"); $attr=$n-Select (); $this->assign ("n",$attr); $this-Show (); } Public functionXiugai ($code=""){//The __action__ method in the From form requires a default value of $code= "" to prevent errors by default!! The Xiugai method needs to implement two methods//1. Display Page//2. Performing Modifications $n= D ("Nation"); if(Empty($_post)){ $nation=$n->find ($code);//Find () method, according to the primary key to find a bar, found a one-dimensional array $this->assign ("Nation",$nation); $this-Show (); }Else{ //2. Modifications $n->create ();//$n is the Model object create (); The method is to automatically collect the form, which ignores the information in the database without column names! such as the confirmation password at the time of registration $r=$n->save ();//save (); method is to modify if($r){ $this->success ("Modified successfully", "Zhuyemian"); }Else{ $this->error ("Modification failed!! "); } //Note: Two Jump methods success and error, used for page jump hints, and can support Ajax submissions. } } Public functionShanchu ($code){ $n= D ("Nation"); $r=$n->delete ($code);//Delete () method executes the deletion of the specified data if($r){ $url= U ("Zhuyemian");//Use the U-shortcut method to create a path to $this->success ("Delete succeeded",$url); }Else{ $this->error ("Delete failed!! "); } } Public functionFu () {$this-Show (); } Public functionzi () {$this-Show (); }}
zhuyemain.html Display Data main Page face
foreachName= "n" item= "V" > <tr> <td>{$v.code}</td> <td>{$v.name}</td> <td><a href= "__controller__/xiugai/code/{$v. code} ">Modify</a> <a href= "__controller__/shanchu/code/{$v. code} "onclick=" return confirm (' OK to delete? ') ' >Delete</a> </td> </tr> </foreach> </table> </body> $v.code}-->
Xiugai Display Page
$ Nation. Code} "/><!--code hidden-- <div> name: <input type=" text " name=" name "value=" { $nation. Name} "/></div> <input type=" Submit "value=" Modify "/> </form> </body>
<!--******************************** Split line **************************************************************** -
Using template inheritance
And the phpcms template footer.html header.html index.html The three page effect and meaning are the same
Make a parent-class page
Then make a child page to inherit the parent class
<extend name= "Fu"/>
<!--This code means: name= "fu" refers to the parent class inside set the head and tail or can set some other content inside!! -
<block name= "Tou" >
<title> Test sub-templates </title>
<!--Here you can refer to some CSS style JS style sheet--
</block>
<block name= "Neirong" >
<div style= "width:100%; height:300px; Background-color: #C3F; " ></div>
</block>
Effect
thinkphp Framework Simple Delete and modify the procedure of the data and the meaning of the template inheritance probably the procedure