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.
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);
}