PHP realizes the addition, deletion, checking and modification function of the database and the complete code php example

jacklove
Release: 2023-04-01 20:24:01
Original
2377 people have browsed it

This article mainly introduces the PHP implementation of database addition, deletion, query and modification functions and the complete code. Friends in need can refer to the following

This article uses: jquery, tp framework

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; 
  } 
 } 
}
Copy after login

TP_3.2.2/Application/Home/View/ school/showdata.html

 
 
 
  
 数据展示界面 

学生信息展示

编号 姓名 年龄 学号 籍贯 操作 操作
{$vo['id']} {$vo['name']} {$vo['age']} {$vo['num']} {$vo['address']} 删除 修改
Copy after login

TP_3.2.2/Application/Home/View/school/stu.html

 
 
 
  
  
  
  学号注册查询系统  


名字:
年龄:
学号:
籍贯:

Copy after login

##TP_3.2.2/Application/Home/View/school/stu.html

 
 
 
  
  
  
  学号注册查询系统  


名字:
年龄:
学号:
籍贯:

Copy after login

Execute and enter in the browser: http://127.0.0.1:90/TP_3.2.2/index.php/Home/Stu/stushow

Click to delete

Revise:



Summary

The above is the PHP implementation of database addition, deletion, check and modification functions and the complete code introduced by the editor. I hope it will be useful to everyone. Help, if you have any questions please leave me a message and the editor will reply to you in time. I would also like to thank you all for your support of the php Chinese website!

Articles you may be interested in:

PHPMAILER implements PHP email function php example

php-app development interface encryption detailed explanation_php skills

Detailed explanation of php curl with csrf-token verification simulation submission method php example

The above is the detailed content of PHP realizes the addition, deletion, checking and modification function of the database and the complete code php example. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!