Welcome Guest, Not a member yet? Register   Sign In
Updating Data, Getting User ID?
#1

[eluser]scm22ri[/eluser]
Hi Everyone,

I wrote syntax allowing my users to update their user information but I'm having a problem. For testing purposes I hard-coded the user_id of 24 into my syntax but I want that user_id to be dynamic. My question is, how would I get my users ID? The below syntax works (I haven't added form validation but I soon will) when it comes to updating user data I have to dynamically get their ID. Looking at the below snytax how would I go about doing that? Thanks everyone.

My Controller

Code:
public function update_records(){
    
  $now = date("Y-m-d H:i:s");
  
  $form_data = array(
  'business' => $this->input->post('business'),
  'user_id' => $this->input->post('user_id'),
  'address' => $this->input->post('address'),
  'state' => $this->input->post('state'),
  'city' => $this->input->post('city'),
  'zip' => $this->input->post('zip'),
  'phone' => $this->input->post('phone'),
  'website' => $this->input->post('website'),
  'email' => $this->input->post('email'),
  'name' => $this->input->post('name'),
  'time' => $now
  );
  
  $this->load->model('Change_data');
  $this->Change_data->update_function_three($form_data);

My Model

Code:
function update_function_three($formdata){
// How would I make '24' dynamic?  
$this->db->where('user_id', '24');
$this->db->update('business',$formdata);
}


Messages In This Thread
Updating Data, Getting User ID? - by El Forum - 10-02-2013, 08:57 PM
Updating Data, Getting User ID? - by El Forum - 10-03-2013, 07:19 AM
Updating Data, Getting User ID? - by El Forum - 10-03-2013, 10:26 AM
Updating Data, Getting User ID? - by El Forum - 10-03-2013, 12:24 PM
Updating Data, Getting User ID? - by El Forum - 10-04-2013, 08:52 AM
Updating Data, Getting User ID? - by El Forum - 10-04-2013, 09:13 AM
Updating Data, Getting User ID? - by El Forum - 10-04-2013, 01:50 PM
Updating Data, Getting User ID? - by El Forum - 10-04-2013, 05:02 PM



Theme © iAndrew 2016 - Forum software by © MyBB