用户
 找回密码
 入住 CI 中国社区
搜索
查看: 4290|回复: 2
收起左侧

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

[复制链接]
发表于 2008-1-25 22:06:31 | 显示全部楼层 |阅读模式
论坛上没有比较详细的说明,呵,我自己写的,玩玩,刚入门,不懂,请大家照顾下
控制器: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 编辑 ]
发表于 2008-1-26 23:50:18 | 显示全部楼层
把 redirect 去掉看看有什么错误提示?
 楼主| 发表于 2008-1-27 16:11:25 | 显示全部楼层
找到原因了,呵呵,原来是不能获取id值
谢谢HEX

本版积分规则