Home >Backend Development >PHP Tutorial > TP 更新数据解决思路
TP 更新数据
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> //个人档案 public function geren(){ if(!isset($_SESSION[C("USER_AUTH_KEY")])){ $msg="请登录"; }else{ $msg=$_SESSION[C("USER_AUTH_KEY")]; } $this->assign('msg',$msg); //==================获取登录信息============================ $gr=M("admin"); $baide=$gr->select(); $this->assign("baide",$baide); $this->assign("title",'极限互动办公自动化系统'); $this->display(); } public function upgr(){//修改edit 内容 header("Content-Type:text/html; charset=utf-8"); $Form = M("admin"); $data['id'] = $_GET['id']; $data['name'] = $_GET['name']; $data['password'] = $_GET['password']; $data['sex'] = $_GET['sex']; $data['bumen'] = $_GET['bumen']; $data['TEL'] = $_GET['TEL']; $data['QQ'] = $_GET['QQ']; $data['email'] = $_GET['email']; $data['dizhi'] = $_GET['dizhi']; $data['img'] = $_GET['img']; if($data){ $upgr=$Form->where('id='.$data['id'])->save($data); if($upgr){ echo "<script type="text/javascript">alert('更新成功');window.navigate('geren');</script>"; }else{ echo "<script type="text/javascript">alert('更新失败');window.navigate('geren');</script>"; } } }
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <volist name="baide" id="baide"> <tr> <td>{$baide.name}</td> <td>{$baide.sex}</td> <td>{$baide.TEL}</td> <td>{$baide.QQ}</td> <td>{$baide.email}</td> <td>{$baide.dizhi}</td> <td><img src="../../%7B%24baide.img%7D" style="max-width:90%" style="max-width:90%" alt=" TP 更新数据解决思路 " ></td> <td> <a href="__URL__/upgr/id/%7B%24baide.id%7D">编辑档案</a> </td> </tr> </volist>
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <volist name="baide" id="baide"> <form action="__URL__/upgr" method="get" name="geren"> <table width="200" border="1"> <tr> <td width="44">姓名</td> <td width="140"><input type="text" name="name" value="{$baide.name}"></td> </tr> <tr> <td width="44">密码</td> <td width="140"><input type="text" name="password" value="{$baide.password}"></td> </tr> <tr> <td>性别</td> <td><input type="text" name="sex" value="{$baide.sex}"></td> </tr> <tr> <td>公司职位</td> <td><input type="text" name="weizhi" value="{$baide.weizhi}"></td> </tr> <tr> <td>公司部门</td> <td><input type="text" name="bumen" title="{$baide.bumen}" value="{$baide.bumen}"></td> </tr> <tr> <td>TEL</td> <td><input type="text" name="TEL" value="{$baide.TEL}"></td> </tr> <tr> <td>QQ</td> <td><input type="text" name="QQ" value="{$baide.QQ}"></td> </tr> <tr> <td>Email</td> <td><input type="text" name="email" value="{$baide.email}"></td> </tr> <tr> <td>住址</td> <td><input type="text" name="dizhi" value="{$baide.dizhi}"></td> </tr> <tr> <td>头像</td> <td><input type="text" name="img" value="{$baide.img}"></td> </tr> <tr> <td><input type="submit" name="保 存" value="保 存"></td> <td><input type="reset" name="清 空" value="清 空"></td> </tr> </table> </form> </volist> <div class="clear"> </div>