Hi guys I´m trying to update table column by using codeigniter, this is my code below.
Controller:
function search2()
{
if ($_POST) {
$Interno=$_POST['Interno'];
}else{
$Interno = '';
}
$this->db->select('empleados.Interno, empleados.Curp, empleados.Nombre, empleados.A_Paterno, empleados.A_Materno, cuentas.Clabe, cuentas.Banco, cuentas.Observaciones, cuentas.Status');
$this->db->from('empleados');
$this->db->join('cuentas',"cuentas.Interno = empleados.Interno AND cuentas.Status !='I'", 'Left');
$this->db->where('empleados.Interno', $Interno);
$q = $this->db->get();
$data = array();
$data['records'] = $q->result_array();
$this ->load -> view('main/indice', $data);
}
function update_Status()
{
$Interno= $this->input->post('Interno');
$data = array(
'Status' => $this->input->post('Inactivo')
);
if($this->consultas_M->update_Status($Interno, $data))
{
echo " update successful...";
}
else
{
echo "update not successful...";
}
}
With function search2, I display results from two tables (that might be the problem) then I want to change the status of table cuentas to 'I' (inactive it is 'A' active by default). So I just want to update that Status column. But it doesn´t do anything. This is my model
function update_Status($Interno,$data)
{
$this->db->where('Interno', $Interno);
$this->db->update('cuentas', $data);
}
'Interno' is the id from the table and also the input name where that id is displayed. Any help will be appreciated
$datais not empty usingprint_r($data);in your controller and also$Interno