将id从URL传递到codeigniter中的许多函数 [英] Pass id getting from URL to many function in codeigniter

查看:73
本文介绍了将id从URL传递到codeigniter中的许多函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从网址获取ID:



I am getting an ID from a url like:

<?php echo base_url();?>Product/product/<?php echo $product->id;?>"



在我的侧栏上使用相同的功能[查看 - >产品/产品]我正确地得到它。但是当我点击侧边栏中的其他功能时Id不会像这样:



我尝试过:




In my sidebar on the same function[view -> Product/product] I am getting it correctly. but when I click some other function in my sidebar the Id is not comming like:

What I have tried:

<pre lang="PHP">public function Product($id)
{
     $this->data['product'] = $this->prod->get_product($id);
    $this->load->view('products/header');
    $this->load->view('products/topnav');
    $this->load->view('products/sidebar',$this->data);
    $this->load->view('products/home',$this->data);
    $this->load->view('products/footer');
}





正如预期的那样在这个页面上工作,但当我跳到我的侧边栏中的不同功能时,id是不工作,因为它没有得到它...像:





it is working on this page as expected, but when I jump to different function in my sidebar the id is not working because it is not getting it... like:

public function Data()
{
    $id=$this->Product($id);
    $this->data['product'] = $this->prod->get_product($id);
     $this->load->view('products/header');
    $this->load->view('products/topnav');
    $this->load->view('products/sidebar', $this->data);
    $this->load->view('products/data');
    $this->load->view('products/footer');

}





我想要的是什么:如何获得我的ID将上面的内容传递给我的所有侧边栏功能。



What I want: How to get the Id which I pass above to all my sidebar functions.

推荐答案

product-> id; ?>
product->id;?>"



在我的侧栏上使用相同的功能[查看 - >产品/产品]我正确地得到它。但是当我点击侧边栏中的其他功能时,我不是喜欢:



我尝试过的事情:




In my sidebar on the same function[view -> Product/product] I am getting it correctly. but when I click some other function in my sidebar the Id is not comming like:

What I have tried:

<pre lang="PHP">public function Product(


id)
{
id) {


this-> data ['product'] =
this->data['product'] =


这篇关于将id从URL传递到codeigniter中的许多函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆