zoukankan      html  css  js  c++  java
  • 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__代表

  • 相关阅读:
    POJ-2096-Collecting Bugs(概率DP)
    2019ICPC南京网络赛总结
    LOJ-6285-数列分块入门9
    LOJ-6284-数列分块入门8
    LOJ-6283-数列分块7
    bzoj2049: [Sdoi2008]Cave 洞穴勘测
    bzoj1010: [HNOI2008]玩具装箱toy
    bzoj1597: [Usaco2008 Mar]土地购买
    bzoj1233: [Usaco2009Open]干草堆tower 单调队列优化dp
    bzoj2442&&codevs4654 单调队列优化dp
  • 原文地址:https://www.cnblogs.com/wangchuang/p/3572720.html
Copyright © 2011-2022 走看看