This time for everyone to bring PHP to implement the database additions and deletions to find out the steps, PHP to implement the database additions and deletions to the attention of the matter, the following is the actual case, together to see.
tp_3.2.2/application/home/controller/stucontroller.class.php
<?php/** * Created by Phpstorm. * User:root * DATE:2018/4/17 * time:16:32 * * * namespace Home\controller; Use Think\controller; Class Stucontroller extends Controller {public Function stushow () {$this->display ("School/stu"); The Public Function GetData () {$Studata = M (' Stu '); $data [' id ']= '; $data [' Name ']=i (' get.name '); $data [' Age ']=i (' get.age '); $data [' num ']=i (' get.num '); $data [' Address ']=i (' get.add '); $Studata->add ($data); $this->success ("Being ... ", U (' Stu/showdata ')); The Public Function ShowData () {$Studata = M (' Stu '); $data = $Studata->select (); $this->assign (' info ', $data); $this->display (' School/showdata '); Public Function del () {$id = I (' get.id '); $Studata = M (' Stu '); $bool = $Studata->where ([' ID ' + $id])->delete (); if ($bool) {echo 1; }else{Echo 0; }} Public Function Updata () {$id = I (' get.id '); $Studata = M (' Stu '); $data = $Studata->where ([' ID ' + $id])->find (); $this->assiGN (' data ', $data); $this->display ("School/upshowdata"); The Public Function updatadeal () {$Studata = M (' Stu '); $id = I (' get.id '); $data [' Name ']=i (' get.name '); $data [' Age ']=i (' get.age '); $data [' num ']=i (' get.num '); $data [' Address ']=i (' get.add '); $bool = $Studata->where ([' ID ' + $id])->save ($data); if ($bool) {$this->showdata (); }else{Echo 0; } } }
tp_3.2.2/application/home/view/school/showdata.html
<! DOCTYPE html> Tp_3.2.2/application/home/view/school/stu.html
<!doctype html>
Tp_3.2.2/application/home/view/school/stu.html
<!doctype html>
Execute in Browser input: Http://127.0.0.1:90/TP_3.2.2/index.php/Home/Stu/stushow
Click Delete
Modify:
Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!
Recommended reading:
PHP Bubble Sort using detailed
PHP Implementation Huffman encoding/decoding steps