PHP implementation of database additions and deletions to the detailed steps

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.