Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 793153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:06:23+00:00 2026-05-14T22:06:23+00:00

I have a working controller and library function, but I now need to pass

  • 0

I have a working controller and library function, but I now need to pass a URI segment to the library for decision making, and I’m stuck.

Controller:

function survey($method)
{
    $id = $this->session->userdata('id');
    $data['member'] = $this->home_model->getUser($id);

    //Convert the db Object to a row array
    $data['manager'] = $data['member']->row();
    $manager_id = $data['manager']->manager_id;
    $data['manager'] = $this->home_model->getUser($manager_id);
    $data['manager'] = $data['manager']->row();
    if ($data['manager']->credits == '0')   {
        flashMsg('warning',"You can't complete the assessment until your manager has purchased credit.");
        redirect('home','location');
    }
    elseif ($data['manager']->test_complete == '3'){
        flashMsg('warning',"You already completed the Assessment.");
        redirect('home','location');                        
    }
    else{
        $data['header'] = "Home";
        $this->survey_form_processing->survey_form($this->_container,$data);
    }
}

Library:

function survey_form($container)
{
           if($method ==1){
    $id = $this->CI->session->userdata('id');
    // Setup fields
    for($i=1;$i<18;$i++){
      $fields["a_".$i] = 'Question '.$i;
    }
    for($i=1;$i<17;$i++){
      $fields["b_".$i] = 'Question '.$i;
    }
    $fields["company_name"] = "Company Name";
    $fields['company_address'] = "company_address";
    $fields['company_phone'] = "company_phone";
    $fields['company_state'] = "company_state";
    $fields['company_city'] = "company_city";
    $fields['company_zip'] = "company_zip";
    $fields['job_title'] = "job_title";
    $fields['job_type'] = "job_type";
    $fields['job_time'] = "job_time";
    $fields['department'] = "department";
    $fields['supervisor'] = "supervisor";
    $fields['vision'] = "vision";
    $fields['height'] = "height";
    $fields['weight'] = "weight";
    $fields['hand_dominance'] = "hand_dominance";
    $fields['areas_of_fatigue'] = "areas_of_fatigue";
    $fields['injury_review'] = "injury_review";
    $fields['job_positive'] = "job_positive";
    $fields['risk_factors'] = "risk_factors";
    $fields['job_improvement_short'] = "job_improvement_short";
    $fields['job_improvement_long'] = "job_improvement_long";
    $fields["c_1"] = "Near Lift";
    $fields["c_2"] = "Middle Lift";
    $fields["c_3"] = "Far Lift";
    $this->CI->validation->set_fields($fields);

    // Set Rules

    for($i=1;$i<18;$i++){
      $rules["a_".$i]= 'hour|integer|max_length[2]';
    }
    for($i=1;$i<17;$i++){
      $rules["b_".$i]= 'hour|integer|max_length[2]';
    }
    // Setup form default values
    $this->CI->validation->set_rules($rules);

        if ( $this->CI->validation->run() === FALSE )
        {
            // Output any errors
            $this->CI->validation->output_errors();
        }
        else
        {
            // Submit form
            $this->_submit();
        }
    // Modify form, first load
    $this->CI->db->from('be_user_profiles');
    $this->CI->db->where('user_id' , $id);
    $user = $this->CI->db->get();
    $this->CI->db->from('be_survey');
    $this->CI->db->where('user_id' , $id);
    $survey =   $this->CI->db->get();
    $user = array_merge($user->row_array(),$survey->row_array());
    $this->CI->validation->set_default_value($user);

    // Display page
    $data['user'] = $user;
    $data['header'] = 'Risk Assessment Survey';
    $data['page'] = $this->CI->config->item('backendpro_template_public') . 'form_survey';
    $this->CI->load->view($container,$data);
            }
            else{
                 redirect('home','location');
            }
}

My library function doesn’t know what to do with Method…and I’m confused. Does it have something to do with instances in my library?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T22:06:23+00:00Added an answer on May 14, 2026 at 10:06 pm

    You can always call the URI Class in your library…

    $CI =& get_instance();
    
    // The segments from the url
    $uri_segments = $CI->uri->segments_array();
    
    // The segments from the route
    $ruri_segments = $CI->uri->rsegments_array();
    

    URI User Guide: http://codeigniter.com/user_guide/libraries/uri.html

    Also, in your library function survey_form, the variable $method isn’t set. I guess you want to know how to set that to get what you want…? so do this:

    function survey_form($container)
    {
        $CI =& get_instance();
    
        $method = $CI->uri->segment(3): // or whichever segment you want
    
        if($method ==1)
        {
            ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 433k
  • Answers 433k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In which method did you put your myView.image = [UIImage… May 15, 2026 at 2:56 pm
  • Editorial Team
    Editorial Team added an answer Whenever you're curious about what's going on under the optimization… May 15, 2026 at 2:56 pm
  • Editorial Team
    Editorial Team added an answer For getting images or other content onto the device, you… May 15, 2026 at 2:56 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.