This article mainly introduces the PHP implementation of database additions and deletions to check the function and complete code, the need for friends can refer to the following
This article uses: jquery, TP framework
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>
<!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:
Summarize
The above is a small part of the introduction of the PHP implementation of the database of the deletion and modification of the function and the full code, I hope that we have some help, if you have any questions please give me a message, small series will promptly reply to you. Thank you very much for the support of PHP Chinese network!
Articles you may be interested in:
PHP phpmailer Implementation of PHP e-mail Function example
Php-app Development Interface Encryption detailed _php tips
PHP Curl with Csrf-token Validation simulation submission method PHP Instance