This time I will bring you a detailed explanation of the steps for adding, deleting, checking and modifying the database in PHP. What are theprecautions for adding, deleting, checking and modifying the database in PHP. The following is a practical case, let’s take a look.
TP_3.2.2/Application/Home/Controller/StuController.class.php
display("school/stu"); } 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("正在。。。",U('Stu/showdata')); } 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"); } 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
数据展示界面 学生信息展示
编号 姓名 年龄 学号 籍贯 操作 操作 {$vo['id']} {$vo['name']} {$vo['age']} {$vo['num']} {$vo['address']} 删除 修改
TP_3.2.2/Application/Home/View/school/stu.html
TP_3.2.2/Application/Home /View/school/stu.html
To execute, enter in the browser: http://127.0.0.1:90/TP_3.2.2/index.php/Home/Stu/stushow Click to delete Modify: I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website! Recommended reading:Detailed explanation of the use of PHP bubble sort
Detailed explanation of the steps to implement Huffman encoding/decoding in PHP
The above is the detailed content of Detailed explanation of the steps to implement database addition, deletion, query and modification in PHP. For more information, please follow other related articles on the PHP Chinese website!