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

RK infotech
  • 61
  • 1
  • 11
  • fetch using in view file. – meet Apr 09 '16 at 12:31
  • yup m doing the same thing still its not working ! – RK infotech Apr 09 '16 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. – meet Apr 09 '16 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 – RK infotech Apr 09 '16 at 12:38
  • try this `$this->load->view("Tax/Tax",array("datacc"=>$datacc));` – Mayank Vadiya Apr 09 '16 at 12:54
  • Everything is fine.I think you getting error some where.Try to remove this `$this->load->view("Templates/header",$this->data);` view. – Shaiful Islam Apr 10 '16 at 00:07
  • @ShaifulIslam From his question it shows that he can access the data in Tax/Tax view so no point its stopping over your commented code – Zeeshan Apr 10 '16 at 06:27
  • @RKinfotech If i am not wrong you can access it in one view right ? – Zeeshan Apr 10 '16 at 06:27
  • @Zeeshan yup i can access it in my one view but can not able to access it in another view – RK infotech Apr 11 '16 at 03:59
  • One view means Tax & not Tax_search right ? Now try shuffling your line of codes this way and tell me in which view you can access now $this->load->view("Tax/Tax",$datacc); $this->load->view("Tax/Tax_Search",$datacc); – Zeeshan Apr 11 '16 at 06:22

1 Answers1

-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

Zeeshan
  • 803
  • 6
  • 15
  • Are you sure you cannot call multiple view? – Shaiful Islam Apr 10 '16 at 00:00
  • Yes damn sure...Because tell me which view will be loaded from there ? – Zeeshan Apr 10 '16 at 06:24
  • Why not test yourself.It will load all the views.How you became damm sure.Test yourself. – Shaiful Islam Apr 10 '16 at 14:40
  • chk this out buddy http://stackoverflow.com/questions/13853127/codeigniter-unable-to-load-multiple-views-in-controller http://stackoverflow.com/questions/17401686/codeigniter-multiple-views-in-one-view If insufficient kindly refer codeigniter documentation for proper way to load multiple views – Zeeshan Apr 11 '16 at 06:20
  • 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. – Shaiful Islam Apr 11 '16 at 08:53
  • For your clarification please learn more about view [here](https://codeigniter.com/user_guide/general/views.html?#loading-multiple-views) – Shaiful Islam Apr 11 '16 at 08:57