while updating my form it retrieves all info from db in respective field but unable to display values in dropdowns
this is my controller for update
function update($a_id)
{
$data['a_id'] = $a_id;
$data['sector'] = $this->sf_model->get_sector();
$data['subsector'] = $this->sf_model->get_subsector();
$data['type'] = $this->sf_model->get_type();
$data['view'] = $this->sf_model->get_account_record($a_id);
$this->form_validation->set_rules('a_name', 'Account Name', 'trim|required|xss_clean|callback_alpha_only_space');
$this->form_validation->set_rules('a_web', 'Website', 'trim|required|xss_clean');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('viewUpdate', $data);
}
else
{
$data = array(
'a_id' => $this->input->post('a_id'),
'a_name' => $this->input->post('a_name'),
'a_website' => $this->input->post('a_web'),
't_id' => $this->input->post('a_type'),
's_id' => $this->input->post('a_sector'),
'ss_id' => $this->input->post('a_subsector'),
'a_billingStreet' => $this->input->post('a_billingStreet'),
'a_billingCountry' => $this->input->post('a_billingCountry'),
'a_mobile' => $this->input->post('a_mobile'),
);
$this->db->where('a_id', $_POST['a_id']);
$this->db->update('account_info', $data);
$this->session->set_flashdata('msg','<div class="alert alert-success text-center">Successfully Updated!</div>');
redirect('salesforce' . $a_id);
}
}
this is my model
function get_account_record($a_id)
{
$this->db->where('a_id', $a_id);
$this->db->from('account_info');
$query = $this->db->get();
return $query->result();
}
function get_type()
{
$results = $this->db->select('t_id, t_name')->from('account_type')->get()->result();
$t_id = array('-SELECT-');
$t_name = array('-SELECT-');
for ($i = 0; $i < count($results); $i++)
{
array_push($t_id, $results[$i]->t_id);
array_push($t_name, $results[$i]->t_name);
}
return $type_result = array_combine($t_id, $t_name);
}
function get_sector()
{
$results = $this->db->select('s_id, s_name')->from('account_sector')->get()->result();
$s_id = array('-SELECT-');
$s_name = array('-SELECT-');
for ($i = 0; $i < count($results); $i++)
{
array_push($s_id, $results[$i]->s_id);
array_push($s_name, $results[$i]->s_name);
}
return $sector_result = array_combine($s_id, $s_name);
}
function get_subsector()
{
$results = $this->db->select('ss_id, ss_name')->from('account_subsector')->get()->result();
$ss_id = array('-SELECT-');
$ss_name = array('-SELECT-');
for ($i = 0; $i < count($results); $i++)
{
array_push($ss_id, $results[$i]->ss_id);
array_push($ss_name, $results[$i]->ss_name);
}
return $subsector_result = array_combine($ss_id, $ss_name);
}
this is the view
<div class="form-group"> <div class="row colbox"> <div class="col-lg-4 col-sm-4"> <label for="a_id" class="control-label">Account ID</label> </div> <div class="col-lg-8 col-sm-8"> <input id="a_id" name="a_id" placeholder="" readonly="readonly" type="text" class="form-control" value="<?php echo $view[0]->a_id; //$a_id;?>" /> <span class="text-danger"><?php echo form_error('a_id'); ?></span> </div> </div> </div> <div class="form-group"> <div class="row colbox"> <div class="col-lg-4 col-sm-4"> <label for="a_name" class="control-label">Account Name</label> </div> <div class="col-lg-8 col-sm-8"> <input id="a_name" name="a_name" placeholder="Enter Account Name" type="text" class="form-control" value="<?php echo $view[0]->a_name; ?>" /> <span class="text-danger"><?php echo form_error('a_name'); ?></span> </div> </div> </div> <div class="form-group"> <div class="row colbox"> <div class="col-lg-4 col-sm-4"> <label for="a_type" class="control-label">Type</label> </div> <div class="col-lg-8 col-sm-8"> <?php
$attributes = 'class = "form-control" id = "a_type"';
echo form_dropdown('a_type',$type,set_value('a_type'),$attributes);?> <span class="text-danger"><?php echo form_error('a_type'); ?></span> </div> </div> </div> <div class="form-group"> <div class="row colbox"> <div class="col-lg-4 col-sm-4"> <label for="a_sector" class="control-label">Sector</label> </div> <div class="col-lg-8 col-sm-8"> <?php
$attributes = 'class = "form-control" id = "a_sector"';
echo form_dropdown('a_sector',$sector,set_value('a_sector'),$attributes);?> <span class="text-danger"><?php echo form_error('a_sector'); ?></span> </div> </div> </div>