Welcome Guest, Not a member yet? Register   Sign In
Help with updating mysql database
#1

[eluser]condoace[/eluser]
I am trying to figure out why my code is not updating my db. It seems that the $id variable from my controller is not being passed to the model - however, if I change it to a normal string (e.g. 5) it works.. any ideas?

CONTROLLER

Code:
function update_campaign(){
  
   $id = $this->uri->segment(3);
      
   /*if(empty($id)){
    
    redirect('admin/index');
  
   }*/
  
   $this->load->model('Model_admin');

   $this->load->library('form_validation');

   if ($this->input->post('submit'))
   {
    
    $id = $this->uri->segment(3);
    
    $name = $this->input->post('name');
    
    $max_qty = $this->input->post('max_qty');
        
    $starting_date = strtotime($this->input->post('starting_date'));
    
    $ending_date = strtotime($this->input->post('ending_date'));
    
    $description = $this->input->post('descr');
    
    $price = $this->input->post('price');
    
    $min_qty = $this->input->post('min_qty');
  
    $this->Model_admin->update_campaign_data($id,$name);
      
    echo 'success';
    
   }  
  
  }

MODEL

Code:
function update_campaign_data($id,$name) {
      
  
   $data = array(
    'name' => $name
   );
  
   $this->db->where('id', $id);
   $this->db->update('campaigns', $data);

  
  }




Theme © iAndrew 2016 - Forum software by © MyBB