Edit in codeigniter

Page

In your controller,

update_controller.php
<?php
class Update_controller extends CI_Controller{
function __construct()
{
parent::__construct();
load->model('update_model');
}

function show_customer_id()
{
$customer_id= $id = $this->uri->segment(3);
$data['single_customer'] = $this->update_model->show_customer_id($customer_id);
$this->load->view('advertising/update_view', $data);
}

function update_customer_id1()
{
$customer_id= $this->input->post('customer_id');
$data = array(
'company_name' => $this->input->post('company_name'),
'address' => $this->input->post('address'),
'phone_number' => $this->input->post('phone_number'),
'contact_person' => $this->input->post('contact_person')
);
$this->update_model->update_customer_id1($customer_id,$data);
$this->load->view('advertising/update_success');
}
}
?>

In your model,

update_model.php

<?php
class update_model extends CI_Model
{
function show_customer_id($data)
{
db->select('*');
$this->db->from('register');
$this->db->where('customer_id', $data);
$query = $this->db->get();
$result = $query->result();
return $result;
}

function update_customer_id1($customer_id,$data)
{
$this->db->where('customer_id', $customer_id);
$this->db->update('register', $data);
}
}
?>

In your view,

update_view.php

<form method="post" action="config->base_url();?>Update_controller/update_customer_id1″>

Customer Id :
<input type="text" id="hide" name="customer_id" value="customer_id; ?>”>
Company Name :
<input type="text" name="company_name" value="company_name; ?>”>
Address :
<input type="text" name="address" value="address; ?>”>
Phone Number :
<input type="text" name="phone_number" value="phone_number; ?>”>
Contact Person :
<input type="text" name="contact_person" value="contact_person; ?>”>

Leave a comment