更新代码点火器错误的行


update rows on codeigniter error

我正在制作这个编辑功能,它没有编辑任何东西。 我是这个东西的新手。 我正在获取我正在编辑的值,但我无法更新或保存它。 此外,如果它无法更新数据库,我将这个重定向到编辑视图,但我收到此错误, '消息:尝试获取非对象的属性

文件名:视图/edit_view.php

行号: 15'

这是代码。

控制器

///编辑

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。 我所做的是我编辑了edit_view。

            <?php
                $data = $content->PROV_ID;
                echo form_open('Provinces/update_row/'.$data);
            ?>

我把 .$data 放在最后,这样 URL 就会变得localhost/foldername/classname/update_row/valueof$data