ThinkPHP框架学习之CRUD
User模块UserAction.class.php
select();//查询数据库 $this->assign('data',$arr);// $this->display(); } /* * 向数据库插入数据 **/ public function add(){ $m=M('User'); $m->username=$_POST['username']; $m->sex=$_POST['sex']; $num=$m->add(); if ($num>0){ $this->success('添加成功','index');//添加成功并返回首页 }else { $this->error('添加失败'); } } /* * 显示添加表单 **/ public function addform(){ $this->display(); } } ?>
首页模板文件index.html
<script> function jump(){ window.location='__URL__/addform'; } </script>
ID号 | 用户名 | 性别 | 操作 |
---|---|---|---|
{$vo.id} | {$vo.username} | {$vo.sex} | 删除|修改 |
添加表单模板addform.html
PHP之友评论