简体   繁体   English

如何更新codeigniter中的输入字段值

[英]How to update input field values in codeigniter

I am a beginner in Codeigniter and using version 3 I am performing update operation so I have store data and now I have created a separate form for update and want to set this form inputs values that are stored in databases我是 Codeigniter 的初学者,正在使用版本 3 我正在执行更新操作,所以我有存储数据,现在我已经创建了一个单独的更新表单,并希望设置此表单输入存储在数据库中的值

My View (update.php)我的观点 (update.php)

```<div class="form-group"> 
<label for="exampleInputEmail1">Title</label>
 <?php echo form_input(['name'=>'title', 'placeholder'=>'Enter title',
 'class'=>'form-control col- md-5',
 'value'=>set_value('title','$post->title')]);?>
 </div>```

My COntroller我的控制器

public function update($id)
    {

        $this->load->model('queries');
    $postt=$this->queries->getSinglePosts($id); 

    $post=$postt->title;

        $this->load->view('update',['post'=>$post]);

    }

My Model我的模特

public function getSinglePosts($id) { $query=$this->db->get_where('tbl_posts',array('id'=>$id)); public function getSinglePosts($id) { $query=$this->db->get_where('tbl_posts',array('id'=>$id));

        if ($query->num_rows() >0 ) {
        return $query->row();
    }

}

Because you've used set_value('title','$post->title')]);因为你用过set_value('title','$post->title')]); in your view file, I think you should remove this line from your controller $post=$postt->title;在您的视图文件中,我认为您应该从控制器中删除这一行$post=$postt->title; and you should pass the whole of $postt variable to your view (make sure that the $postt is not an array of objects).并且您应该将整个$postt变量传递给您的视图(确保$postt不是对象数组)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Codeigniter同时更新从foreach输入字段派生其值的多个数据库记录 - Simultaneously update multiple database records deriving their values from foreach input field using codeigniter 如何在CodeIgniter更新中更新特定字段? - How to update specific field in CodeIgniter update? 如何通过输入字段值和查询结果更新Amcharts的数据提供者 - how to update the dataprovider of Amcharts by Input field values and query results 如何使用codeigniter在同一字段中搜索2个值? - How to search for 2 values in the same field with codeigniter? Codeigniter - 重新填充输入字段 - Codeigniter - Repopulation Of Input Field 使用PHP在CodeIgniter中使用用户输入的值更新数据库表 - Update Database tables with values input by user in CodeIgniter using PHP 如何在codeigniter中将复选框值带到更新页面 - how to bring checkbox values to update page in codeigniter Codeigniter 更新表中的值 - Codeigniter update values in a table 对于动态创建输入字段,仅接收数据库的数组符号,而在Codeigniter中未接收到输入值 - Receiving only Array notation to data base for dynamic create input field ,not received input values in Codeigniter 如何通过Codeigniter中的.ajax()方法获取值并在输入字段中显示值? - how to get value by .ajax() method in codeigniter and show the value in input field?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM