TP 복습4

7733 단어 T
    <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(' ');
            }
        }
    }
?>

-------------------------------------------------------------------
<script>
            function jump(){
                window.location="/thinkphp/index.php/User/add";
            }
        </script>

__URL__대표

좋은 웹페이지 즐겨찾기