2013-07-11 80 views
-2

如何將帖子變量傳遞給網址?我可以從網址讀取它,但我不能把它... 我有什麼至今:$route['shop/find/(:any)']= "shop/find/$1";航線上,我的看法find.php,我的功能`將帖子變量傳遞給網址

function find() 
    { 
      $this->load->model('shopFront/find'); 
      $this->load->model('currency'); 
      $this->load->model('shopFront/calculate'); 
      $this->load->model('shop/proccess'); 
      $data = $this->commondatashop->general(); 
      $inputSlug = $this->input->post('findSlug'); 
      $data['tofind'] = $inputSlug; 
      $data['cartInfo'] = $this->shopcart; 
      $data['Currency'] = $this->currency; 
      $data['Calculate'] = $this->calculate; 
      $data['Proccess'] = $this->proccess; 
      $data['title'] = "1.4.U Shop | Find"; 
      $finder = $this->find; 
      $data['finderservice'] = $finder; 
      $data['user_id'] = $this->session->userdata('user_id'); 
      $data['user_name'] = $this->session->userdata('user_name'); 
      $this->load->view('shop/top/topNew',$data); 
      $this->load->view('shop/content/find',$data); 

      //footer 
      $curravailable = $this->calculate->getCurrencies(); 
      if ($curravailable !== false) 
      { 
       $data['currencies'] = $curravailable; 
      } 
      else 
      { 
       $data['currencies'] = 'none'; 
      } 
      $this->load->view('shop/footer',$data); 


    }` 

我怎樣才能發佈變量的find()函數與網址段?

回答

0

你需要有找到接受參數使用默認的

function find($i=0) { 
    //$i is whatever is in the URL or defaults to 0 
+0

是的但我後發現找到函數r edirects到查找查看器和網址保持mysite /找到而不是mysite/find /項目 –

+0

如果你發佈到'yoursite/controller/find',你不會得到那個變量,你需要發佈到'yourside/controller/find/id'或發送POST數據,而不是從params收集,你可以使用CI的輸入類。即$ i ='$ this-> input-> post('post_var_name');' – bizzehdee

+0

所以我需要改變這個 <?php echo form_open('shop/find','find'); ?> <?php echo form_close(); ?> 用$ this-> input-> post代替提交? –

0

在你看來:

echo form_open('/shop/find'); 
echo form_input('findSlug',''); 
echo form_submit('submit', 'Submit'); 
echo form_close(); 

控制器:

$data[slug] = $this->input->post('findSlug'); 

你需要下載的形式幫助過