dswy34539
2018-03-03 05:38
浏览 62
已采纳

Codeigniter:获取页面的URI段并将其添加到其重定向页面的URL中

So I have these 2 pages IF the URL of page1 is: http://localhost/project/page1/page1/5

And there's a link in that page that redirects to page2 with the URL:

http://localhost/project/page2/page2/2
(its 3rd segment - 2 is from dropdown value selected)

Is it possible to make the redirected page - page2 with a URL like this: http://localhost/project/page2/page2/5/2

-so that I could do something with page1's value, like querying dynamically in the database.

VIEW in page1:

<div class="form-group form-inline">
  <select id="p2_val">

      <?php 
          foreach($v_p2 as $row) {
      ?> 
      <option 
          value="<?php  echo base_url('page2/page2/').$row->p2_val;?>">
          <?php echo $row->p2_num; ?>
      </option>
      <?php }  ?> 

  </select>

      <input  class="SubmitButton" type="submit" 
      name="SUBMITBUTTON" value="Submit" />
</div>

Controller in page1:

class Page1 extends CI_Controller{

     public function __construct()
        {
            parent::__construct(); 
            $this->load->model('page1_model');

        }

    public function page1(){
        if($this->session->userdata('logged')){

            $this->load->model('page1_model');

            $data["v_p2"] = $this->page1_model->v_p2($this->session->userdata('user_id'));

            $this->load->view('pages/page1', $data);

            $this->load->view('templates/footer');

        }

    }

Controller of page2:

class Page2 extends CI_Controller{

     public function __construct()
        {
            parent::__construct(); 
            $this->load->model('page2_model');

        }

    public function page2(){
        if($this->session->userdata('logged')){

            $this->load->model('page2_model');

            $data["get_p2"] = $this->page2_model->get_p2($this->session->userdata('user_id'));

            $this->load->view('pages/page2', $data);

            $this->load->view('templates/footer');

        }

    }

2条回答 默认 最新

相关推荐 更多相似问题