【问题标题】:how to redirect the page with data through codeigniter如何通过codeigniter用数据重定向页面
【发布时间】:2015-10-25 17:08:02
【问题描述】:
$data['family_info'] = $this->Registration->getFamilyDetails($student_id);
redirect("Application/studentRegistration/".$student_id,$data);
$this->load->view("Application/familyInfo/".$student_id);

我想用一些数据将控制器重定向为 mysql 记录集,但是当我尝试重定向时 - 它现在返回数据, 在尝试查看函数时,我可以,但我无法将学生 ID 作为查询字符串发送。

CI/index.php/Application/familyInfo/182

取消打包以将数据获取到此页面并使用重定向。
使用视图我可以获取数据但无法获取查询字符串。

【问题讨论】:

    标签: php mysql codeigniter redirect


    【解决方案1】:

    重定向页面后,您的代码将离开控制权。

    重定向后加载视图不起作用。

    您可以做的是:您已经通过重定向发送给我们。

    重定向后,在目标页面,根据传入的id获取数据。

    【讨论】:

      【解决方案2】:

      您只能通过重定向传递 id 而不能将数据作为$this->load->view 传递,以获取数据只需这样做:

      public function studentRegistration($student_id)
      {
          $data['family_info'] = $this->Registration->getFamilyDetails($student_id);
          $this->load->view('Application/studentRegistration/'.$student_id,$data);
      }
      

      【讨论】:

      • 当我尝试上面的语句时,我得到了错误,找不到错误页面。 Application/familyInfo/182.php 帮助 Imran
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-07
      • 2014-07-14
      • 1970-01-01
      • 1970-01-01
      • 2021-10-16
      • 1970-01-01
      相关资源
      最近更新 更多