PHP实现数据库的增删查改功能及完整代码
发布时间:2021-05-24 00:12:27 所属栏目:PHP教程 来源:网络整理
导读:本文用到:jquery、tp框架 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['n
本文用到:jquery、tp框架 TP_3.2.2/Application/Home/Controller/StuController.class.phpdisplay("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数据展示界面学生信息展示
|