0

This is my Code Of Controller

    $datacc['user_id'] = $this->user_id;
    $this->load->view("Templates/header",$this->data);
    $this->load->view("Tax/Tax_Search",$datacc);
    $this->load->view("Tax/Tax",$datacc);

in this, i want to pass "$datacc" to my both view files (Tax.php And Tax_Search) but $datacc can't pass to Tax_Search.php file

can anyone help?

Thank You

10
  • fetch using <?php echo $user_id; ?> in view file. Commented Apr 9, 2016 at 12:31
  • yup m doing the same thing still its not working ! Commented Apr 9, 2016 at 12:33
  • try to print value of echo $this->user_id; exit; before "$datacc['user_id'] = $this->user_id;" code in controller. and check $this->user_id return value or not. Commented Apr 9, 2016 at 12:35
  • if i print "echo $this->user_id; exit;" before "$datacc['user_id'] = $this->user_id;" it prints Current UserId which i want in view Commented Apr 9, 2016 at 12:38
  • try this $this->load->view("Tax/Tax",array("datacc"=>$datacc)); Commented Apr 9, 2016 at 12:54

1 Answer 1

-1

You cannot call multiple view in one controller function. This can be done in view file.

I suggest you that you should first create a template file and in that template call your views like this

template.php
   $this->load->view("Tax/Tax");
   $this->load->view("Tax/Tax_search");
   <?php echo $content; ?>
   $this->load->view("Tax/footer");

Let me know if you have queries

Sign up to request clarification or add additional context in comments.

6 Comments

Are you sure you cannot call multiple view?
Yes damn sure...Because tell me which view will be loaded from there ?
Why not test yourself.It will load all the views.How you became damm sure.Test yourself.
chk this out buddy stackoverflow.com/questions/13853127/… stackoverflow.com/questions/17401686/… If insufficient kindly refer codeigniter documentation for proper way to load multiple views
Man why don't you test yourself calling multiple view inside controller.The link you provided top answer wrote wrong You cannot call multiple view in one controller function. You can call multiple view inside controller and inside view even inside model. There is no rule for proper way to call.You need to write your way.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.