zoukankan      html  css  js  c++  java
  • TP框架修改操作

    function update()
    {
        $info=M("info");
        $code = $_GET["code"];
        if(empty($_POST))
        {
            $attr=$info->find($code);
            $minzu=$info->table("nation")->distinct(true)->select();
            $this->assign("nation",$minzu);
            $this->assign("sj",$attr);
            $this->display();
        }
        else
        {
            $info->create();
    $code1=$_POST["Code"]; $info->Sex=$_POST["Sex"]=="男"?true:false; $att = $info->where("code='{$code1}'")->save(); if($att) { $this->success("修改成功",U("main"),3); } else { $this->error("修改失败","update",3); } } }
    <h1>修改页面</h1>
    <form action="__ACTION__" method="post">
    <div>代号:<input type="text" name="Code" value="<{$sj.code}>"/></div><br />
    <div>姓名:<input type="text" name="Name" value="<{$sj.name}>"/></div><br />
    <div>性别:
    <input type="text" name="Sex" value="<{$sj['sex']==true?'男':'女'}>"></option>
    </div><br />
    <div>民族:
    <select name="Nation">
    <foreach name="nation" item="v">
    <if condition="$sj['nation']==$v['code']">
    <option value="<{$v.code}>" selected="selected"><{$v.name}></option>
    <else/>
    <option value="<{$v.code}>"><{$v.name}></option>
    </if>
    
    </foreach>
    </select>
    </div><br />
    <div>生日:<input type="text" name="Birthday" value="<{$sj.birthday}>"/></div><br />
    <div><input type="submit" value="修改"/></div>
    </form>
  • 相关阅读:
    Luogu P1396 营救
    Luogu P1339 热浪Heat Wave
    哈夫曼树学习笔记
    题解 CF1372C
    题解 CF 1372 B
    题解 CF 1372A
    题解 UVA1193 Radar Installation
    题解 洛谷 P2287 [USACO07NOV]Sunscreen G
    洛谷 P1080 国王游戏 题解
    牛客练习赛 66C公因子 题解
  • 原文地址:https://www.cnblogs.com/yuchao19950412/p/5733256.html
Copyright © 2011-2022 走看看