$update_data = array( 'username' => $value1, 'userpassword' => $value2, 'userfullname' => $value3, ); $this->public_model->update_some_fields_with_where($update_data,'tbluser','userid = '.$this->uri->segment(3)); $sql="SELECT id,title_en FROM api_blog WHERE id > 0"; $query=$this->db->query($sql); if($query->num_rows() >0){ foreach($query->result() as $row){ $update_data = array( 'url' => clean_url($row->title_en), ); $this->api_model->update_some_fields_with_where($update_data,'api_blog',"id = '".$row->id."'"); } } $query->free_result();