发新话题
打印

为什么我的更新不成功!?

本主题由 沧蓝 于 2008-4-1 19:07 移动

为什么我的更新不成功!?

论坛上没有比较详细的说明,呵,我自己写的,玩玩,刚入门,不懂,请大家照顾下
控制器:ecms.php
复制内容到剪贴板
PHP 代码:
<?php
class Ecms extends Controller {
function Ecms()
{
  parent::Controller();
 
  $this->load->helper('url');
  $this->load->helper('form');
 
}
function index()
{
  $this->load->database();
  $data['title']="ECMS";
  $data['heading']="报障内容系统";

  $this->load->view('ecms_view',$data);
}

function product()
{
  $this->load->database();
  $data['title']="报障产品维护";
  $data['heading']="报障产品";

  $data['query']=$this->db->get('product');
 
  $this->load->view('product_view',$data);
}

function product_insert()
{
  $this->load->database();
  $this->db->insert('product',$_POST);
 
  redirect('ecms/product/');
}

function product_edit()
{
  $this->load->database();
  $data['title']="更新报障产品";
  $data['heading']="更新报障产品";
  $this->db->where('id',$this->uri->segment(3));
  $data['query']=$this->db->get('product');
 
  $this->load->view('product_edit',$data);
}

function product_update()
{
  $this->load->database();

  $this->db->set('products',$_POST['products_name']);
  $this->db->where('id',$this->uri->segment(3));
  $this->db->update('product');
 
  redirect('ecms/product/');
}
}
?>
VIEW:product_edit.php
复制内容到剪贴板
PHP 代码:
<html>
<head>
<title><?=$title?></title>
</head>
<body>
<h1><?=$heading?></h1>
<p><?=anchor('ecms','返回主页');?></p>

<?=form_open('ecms/product_update');?>
<?php if($query->num_rows()==1):?>
<?php foreach($query->result() as $row):?>
<p>报障产品:<input type="text" value=<?=$row->products;?> name="products_name"/></p>
<?php endforeach;?>
<input type="submit" value="更新数据"/>
<?php else:?>
<?php echo"传递的参数数量错误,请返回!";?>
<?php endif;?>
</form>
</body>
</html>
为什么我的update不成功呢?此页面没有报错!请教高人!!!

[ 本帖最后由 tanqimin 于 2008-1-25 22:38 编辑 ]

TOP

把 redirect 去掉看看有什么错误提示?
QQ: 49489680
MSN: zhaochang_tj AT hotmail DOT com

TOP

找到原因了,呵呵,原来是不能获取id值
谢谢HEX

TOP

发新话题