I already can update my data from database but the problem is i just want to update one data, but when I enter the new data it updated all of data in the database table
this is View:
<form method="post" action="<?php echo base_url() ?>user/update_user_data">
<div class="form-group">
<label> Enter New first name</label>
<input type="text" name="firstname" class="form-control" />
</div>
<div class="form-group">
<label> Enter New last name </label>
<input type="text" name="lastname" class="form-control" />
</div>
<div class="form-group">
<label> Enter New fullname </label>
<input type="text" name="fullname" class="form-control" />
<div class="form-group">
<input type="submit" name="update" value="Update" class="btn btn-info" />
</div>
this is model:
function update_data($id = FALSE)
{
if($id == FALSE){
$query = $this->db->get('user');
return $query->result_array();
}
$query = $this->db->get_where('user', array('id' => $id));
return $query->row_array();
}
public function update_user_data($data)
{
$data = array('firstname' => $this->input->post('firstname'),
'lastname' => $this->input->post('lastname'),
'fullname' => $this->input->post('fullname')
);
$this->db->update("user", $data);
}
this is controller:
public function update_data($id = NULL)
{
$data['us'] = $this->User_Model->update_data($id);
if (empty($data['us'])) {
show_404();
}
$this->load->view('user/update-user', $data);
}
public function update_user_data()
{
$data['title'] = 'Update user';
$this->load->library('upload');
$data = array('upload_data' => $this->upload->data());
$this->User_Model->update_user_data($data);
redirect('user/index');
}
Im just a beginner please respect thanks If there is something wrong with my code please let me know. Its working by the way, the only problem is once I update the users data it updating all of the data in the database.

updatingthe whole table notinserting