TP复习4
<script>
window.onload=function(){
if(<{$data.sex}>==0){
document.getElementsByName('sex')[1].checked='checked';
}else{
document.getElementsByName('sex')[0].checked='checked';
}
}
</script>
<?php
class UserAction extends Action{
public function index(){
$m=M('User');
$arr=$m->select();
//var_dump($arr);
$this->assign('data',$arr);
$this->display();
}
public function del(){
$m=M('User');
$id=$_GET['id'];
$count=$m->delete($id);
if($count>0){
$this->success('数据删除成功');
}else{
$this->error('数据删除失败');
}
}
/*
* 显示修改页面
* */
public function modify(){
$id=$_GET['id'];
$m=M('User');
$arr=$m->find($id);
$this->assign('data',$arr);
$this->display();
}
public function update(){
$m=M('User');
$data['id']=$_POST['id'];
$data['username']=$_POST['username'];
$data['sex']=$_POST['sex'];
$count=$m->save($data);
if($count>0){
$this->success('数据修改成功','index');
}else{
$this->error('数据修改失败');
}
}
/*
* 添加页面
* */
public function add(){
$this->display();
}
public function create(){
$m=M('User');
$m->username=$_POST['username'];
$m->sex=$_POST['sex'];
$idNum=$m->add();
if($idNum>0){
$this->success('数据添加成功','index');
}else{
$this->error('数据添加失败');
}
}
}
?>
-------------------------------------------------------------------
<button onclick="jump()">添加用户</button>
<script>
function jump(){
window.location="/thinkphp/index.php/User/add";
}
</script>
__URL__代表
TP复习4的更多相关文章
- TP复习17
三大自动,自动创建,自动验证,自动完成
- TP复习16
'APP_GROUP_LIST' => 'Home,Admin', //项目分组设定'DEFAULT_GROUP' => 'Home', //默认分组 开分组复制上面 AjaxReturn
- TP复习15
## ThinkPHP 3.1.2 URL#讲师:赵桐正微博:http://weibo.com/zhaotongzheng 本节课大纲:一.URL规则 1.默认是区分大小写的 2.如果我们不想区分大小 ...
- TP复习14
## ThinkPHP 3.1.2 控制器的模块和操作#讲师:赵桐正微博:http://weibo.com/zhaotongzheng 本节课大纲:一.空模块和空操作 1.空操作 function _ ...
- TP复习13
## ThinkPHP 3.1.2 模板的使用技巧#讲师:赵桐正微博:http://weibo.com/zhaotongzheng 本节课大纲:一.模板包含 <include file=&quo ...
- TP复习12
四.特殊标签 1.比较标签 eq或者 equal 等于 neq 或者notequal 不等于 gt 大于 egt 大于等于 lt 小于 elt 小于等于 heq 恒等于 nheq 不恒等于 2.范围标 ...
- TP复习11
## ThinkPHP 3.1.2 模板中的基本语法#讲师:赵桐正微博:http://weibo.com/zhaotongzheng 本节课大纲:一.导入CSS和JS文件 1.css link js ...
- TP复习10
i * { padding:0; margin:0; } 居中 ## ThinkPHP 3.1.2 模板中的变量#讲师:赵桐正微博:http://weibo.com/zhaotongzheng 本节课 ...
- TP复习9
配置文件 'TMPL_TEMPLATE_SUFFIX'=>'.html',//更改模板文件后缀名'TMPL_FILE_DEPR'=>'_',//修改模板文件目录层次'TMPL_DETECT ...
- TP复习8
## ThinkPHP 3.1.2 视图#讲师:赵桐正微博:http://weibo.com/zhaotongzheng 本节课大纲:一.模板的使用 (重点) a.规则 模板文件夹下[TPL]/[分组 ...
随机推荐
- iOS学习笔记之ARC内存管理
iOS学习笔记之ARC内存管理 写在前面 ARC(Automatic Reference Counting),自动引用计数,是iOS中采用的一种内存管理方式. 指针变量与对象所有权 指针变量暗含了对其 ...
- IGF职业组比赛
IGF职业组比赛 参赛资格: 面向亚太区所有独立游戏开发者(参见详细规则) 截止日期: 2015年7月20日 2015年IGF职业组七大奖项设置如下: * 最佳游戏(RMB20, 000) * 最佳移 ...
- 重新开始吧(ADB+AndroidManifest.xml)
我现在默认已经搭建好了开发环境.如果没有,可以参见去Google一下,或者我上两篇文章中也有提到. 先补充一点: SDK不用FQ.也能更新 修改hosts文件 下载sdk版本: 在hosts文件中追加 ...
- WCF基礎
參考:http://www.cnblogs.com/MeteorSeed/archive/2012/04/24/2399455.html http://www.cnblogs.com/scy25114 ...
- httpcomponents 学习1--并发多线程GET
package org.apache.http.examples.client; import org.apache.http.HttpEntity; import org.apache.http.H ...
- HTTP Status 500 - Servlet.init() for servlet htmlWebConfig threw exception
HTTP Status 500 - Servlet.init() for servlet htmlWebConfig threw exception
- poj 2594 Treasure Exploration(最小路径覆盖+闭包传递)
http://poj.org/problem?id=2594 Treasure Exploration Time Limit: 6000MS Memory Limit: 65536K Total ...
- sql中获得时间的参数
(----我错了,以下非php.php用例:FORM_UNIXTIME($time, '%H')取小时数.---) 返回表示指定日期的指定日期部分的整数. 语法 DATEPART ( datepart ...
- Android中使用gzip传递数据
HTTP协议上的GZIP编码是一种用来改进WEB应用程序性能的技术.大流量的WEB站点常常使用GZIP压缩技术来减少文件大小,减少文件大小有两个明显的好处,一是可以减少存储空间,二是通过网络传输文件时 ...
- POJ 1947 Rebuilding Roads (树dp + 背包思想)
题目链接:http://poj.org/problem?id=1947 一共有n个节点,要求减去最少的边,行号剩下p个节点.问你去掉的最少边数. dp[u][j]表示u为子树根,且得到j个节点最少减去 ...