时间:2021-07-01 10:21:17 帮助过:4人阅读
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
| ID号 | 用户名 | 性别 | 操作 |
|---|---|---|---|
| {$vo.id} | {$vo.username} | {$vo.sex} | 删除|修改 |
http://www.bkjia.com/PHPjc/756256.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/756256.htmlTechArticleUser模块UserAction.class.php select();//查询数据库$this->assign('data',$arr);//$this->display();}/* * 向数据库插入数据 **/public function add(){$m=M('User');$m->user...