Welcome Guest, Not a member yet? Register   Sign In
Failed to Update data inside Input field
#1

I'm trying to update my data inside INPUT FIELD using a UPDATE Button. In the image below, I'll type new data in the field and press Edit button and my DB will be updated.

[Image: pjJf6PV.jpg]

But I'm stuck in where clause.

$this->output->enable_profiler(TRUE); was showing that in query WHERE 'id'=NULL.  My query can't specify the id field.

*Called the model inside construct already.
view :
PHP Code:
<?php if(isset($records)) : foreach($records  as $row): ?>
<?php  echo form_open
('main/update'?>
 
<td> <input type="text" name="edit_tname" value="<?php echo $row->tname ;?>"/> </td>
<td> <input type="text" name="edit_time" value="<?php echo $row->time?>" /></td>

<td> <input type="submit" value="Edit"> </td>

<?php echo form_close();?>

<?php endforeach; ?>

controller :
PHP Code:
public function update_task()
 
       {
 
          $this->model_users->updateM();
 
          redirect('main');
 
       

model:
PHP Code:
public function updateM()
 
           {
 
               $updated_data = array(
 
                   'tname'=> $this->input->post('edit_tname'),
 
                   'time'=> $this->input->post('edit_time')
 
                   );
 
                   
                $this
->db->where('id'$this->uri->segment(3));
 
               $this->db->update('tasks'$updated_data);
 
           
Reply
#2

put the id in hidden input, or as part of form_open url
Reply
#3

As Gadelat said: add a hidden field.
Like this:
Code:
<?php echo form_hidden('id', $row->id);?>

In your controller, read the value:
Code:
$id = $this->input->post('id');
Reply
#4

Yap it worked, Thanks Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB