Php 更新codeigniter错误上的行
我做这个编辑功能,它不编辑任何东西。我对这件事不熟悉。我正在获取我正在编辑的值,但我无法更新或保存它。此外,如果无法更新数据库,我会将此视图重定向到编辑视图,但我收到了以下错误,`Message:tryingtogetpropertyofnonobject 文件名:views/edit_view.php 电话号码:15` 这是密码 控制器 ///编辑Php 更新codeigniter错误上的行,php,codeigniter,sql-update,codeigniter-3,Php,Codeigniter,Sql Update,Codeigniter 3,我做这个编辑功能,它不编辑任何东西。我对这件事不熟悉。我正在获取我正在编辑的值,但我无法更新或保存它。此外,如果无法更新数据库,我会将此视图重定向到编辑视图,但我收到了以下错误,`Message:tryingtogetpropertyofnonobject 文件名:views/edit_view.php 电话号码:15` 这是密码 控制器 ///编辑 public function update(){ $data['content'] = $this->Provinces_Mod
public function update(){
$data['content'] = $this->Provinces_Model->getrow();
$data['content_view'] = 'Provinces/edit_view';
$this->templates->admin_template($data);
}
public function update_row(){
if($this->Provinces_Model->update()){
redirect('Provinces/index');
}else{
$this->update();
}
}
模型
////编辑
public function getrow(){
$this->db->where('PROV_ID', $this->uri->segment(3));
$query = $this->db->get($this->table);
return $query->row();
}
public function update(){
$id = $this->input->post('PROV_ID');
$input = array(
'PROVINCE' => $this->input->post('PROVINCE')
);
$this->db->where('PROV_ID', $this->uri->segment(3));
$update = $this->db->update($this->table, $input);
}
阅读视图
<td><?php echo anchor("Provinces/update/$i->PROV_ID","<i class='fa fa-edit'>" ); ?></td>
edit view
<div>
<center>
<fieldset>
<?php
echo form_open('Provinces/update_row');
?>
<p>
<label class="field" for="PROVINCE"><span>*</span>Province Name:</label>
<input type = "text" name="PROVINCE" class ="textbox-300" value= "<?php echo $content->PROVINCE; ?>">
<label class = "error"><?php echo form_error("PROVINCE"); ?></label>
</p>
<?php
echo form_submit('submit','Update');
echo form_close();
?>
</fieldset>
</center>
</div>
*省名:
当我调用update_row()时,我的url变为localhost/foldername/classname/update_row,如您所见,$this->uri->segment(3)
变为null。我所做的是编辑了“编辑”视图
<?php
$data = $content->PROV_ID;
echo form_open('Provinces/update_row/'.$data);
?>
我把.$data放在末尾,这样url就会变成localhost/foldername/classname/update\u row/valueof$data
试试$query->result()代码>而不是$query->row()
它在$query->row()上正常工作代码>获取要编辑的数据没有问题。问题是,我无法在数据库中更新它。您将获得错误编辑视图。你应该发布你的edit\u view.php文件code.Putvar\u dump($content);退出在edit_view.php
的第一行,复制您得到的信息。在edit_视图中显示第15行