PHP implementation of database additions and deletions function and complete code PHP example

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

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.