修改栏目名称,修改页获取id的父栏目

public function cateedit(){
    	$catModel = D('Cat');
    	if(IS_POST){
    	$cat_id = I('cat_id');
    	if($catModel->where('cat_id=' . $cat_id)->save($_POST)){
    		$this->redirect('Admin/cat/catelist');exit;
    	}

}
    	
    	$this->assign('gettree',$catModel->gettree());//获取全部数据数据传给view模板
        $this->assign('catinfo',$catModel->find(I('cat_id')));//获取$catModel->find(I('cat_id')数据传给view模板
        $this->display();//

    }

<?php
namespace Admin\Model;
use Think\Model;

class CatModel extends Model{
    public function gettree(){
        return $this->select();
    }


}

点击编辑的时候,首先判断有没有post过来数据?没有传过来数据说明点击编辑的时候进入的还没有更新提交

$this->assign('gettree',$catModel->gettree());//获取全部数据数据传给view模板
$this->assign('catinfo',$catModel->find(I('cat_id')));//获取$catModel->find(I('cat_id')数据传给view模板
$this->display();//
获取cat栏目下的所有信息    传送给view模板

然后根据id获取修改前的的内容  传值给view模板

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ECSHOP 管理中心 - 添加分类 </title>
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="__PUBLIC__/Admin/css/general.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/Admin/css/main.css" rel="stylesheet" type="text/css" />
</head>
<body>

<h1>
<span class="action-span"><a href="catelist.html">商品分类</a></span>
<span class="action-span1"><a href="#">ECSHOP 管理中心</a> </span><span id="search_id" class="action-span1"> - 添加分类 </span>
<div style="clear:both"></div>
</h1>

<div class="main-div">
  <form action="{:U('admin/cat/cateedit')}" method="post" name="theForm" enctype="multipart/form-data">
  <table width="100%" id="general-table">
      <tr>
        <td class="label">分类名称:</td>
        <td>
          <input type='text' name='cat_name' maxlength="20" value='{$catinfo.cat_name}' size='27' /> <font color="red">*</font>
        </td>
      </tr>
      <tr>
        <td class="label">上级分类:</td>
        <td>
          <select name="parent_id">
              <!-- <option value="0">leixing</option> -->
              <foreach name="gettree" item="c">
              <option value="{$c.cat_id}"  {$c['cat_id']==$catinfo['parent_id']?'selected':''}  >{$c.cat_name}</option>
              </foreach>

              <!---
                        <option value="3">  GSM手机</option>
                        <option value="4">  3G手机</option>
                        <option value="5">  双模手机</option>
                        <option value="6">手机配件</option>
                        <option value="7">  充电器</option>
                        <option value="8">  耳机</option>
                        <option value="9">  电池</option>
                        <option value="11">  读卡器和内存卡</option>
                        <option value="12">充值卡</option>
                        <option value="13">  小灵通/固话充值卡</option>
                        <option value="14">  移动手机充值卡</option>
                        <option value="15">  联通手机充值卡</option> -->
                      </select>
        </td>
      </tr>

      <tr>
        <td class="label">分类描述:</td>
        <td>
          <textarea name='intro' rows="6" cols="48">{$catinfo.intro}</textarea>
        </td>
      </tr>
      </table>
      <div class="button-div">
        <input type="submit" value=" 确定 " />
        <input type="reset" value=" 重置 " />
      </div>
    <!-- <input type="hidden" name="act" value="insert" />
    <input type="hidden" name="old_cat_name" value="" />-->
    <input type="hidden" name="cat_id" value="{$catinfo.cat_id}" /> 
  </form>
</div>

<div id="footer">
共执行 3 个查询,用时 0.021687 秒,Gzip 已禁用,内存占用 2.081 MB<br />
版权所有 &copy; 2005-2010 上海商派网络科技有限公司,并保留所有权利。</div>

</body>
</html>



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值