![]() |
function call from url - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: function call from url (/showthread.php?tid=4543) Pages:
1
2
|
function call from url - El Forum - 12-01-2007 [eluser]airparkroad[/eluser] I am trying to do this one thing.. I want to type into the url, say, ../index.php/directory/product/22345 and make it appear somewhere on my web page, product ID: 22345 How do I achieve this? btw, code igniter rocks!!! +P function call from url - El Forum - 12-01-2007 [eluser]xwero[/eluser] Code: echo $this->uri->segment(3); function call from url - El Forum - 12-01-2007 [eluser]airparkroad[/eluser] <html> <body> <?php echo $this->uri->segment(3); ?> </body> </html> Above code is how I wrote it on directory_view.php file. And I typed ../index.php/directory/product/23455 It gave me a 404 error. Am I doing something wrong here? function call from url - El Forum - 12-01-2007 [eluser]xwero[/eluser] do you have controller named directory and a method named product? to test you can do following in your controller Code: function product() function call from url - El Forum - 12-01-2007 [eluser]airparkroad[/eluser] Yes. I have a controller named directory. And I have a function named product. How do I call the function product from the view file? Thanks a lot for your help. function call from url - El Forum - 12-01-2007 [eluser]xwero[/eluser] it's the other way around ![]() Code: function product() function call from url - El Forum - 12-01-2007 [eluser]airparkroad[/eluser] hmm..okay.. so.. for my controller file, called directory,, i have functions directory() index() (-> this with $data) and product() I'm calling $this->load->view('directory_view') inside of index() function. From directory_view file, I do, echo $this->uri->segment(2) echo $this->uri->segment(3) Then, I type ../index.php/directory/product/123 No matter what I put inside of product() function, it would give me 404 error. But if I do ../index.php/directory/directory/123 Then it would show directory 123. How do I solve this problem? function call from url - El Forum - 12-01-2007 [eluser]xwero[/eluser] can i see your controller function call from url - El Forum - 12-01-2007 [eluser]Michael Wales[/eluser] Controller Code: Class Directory extends Controller { View: Code: <?= $this->uri->segment(3); ?> function call from url - El Forum - 12-01-2007 [eluser]airparkroad[/eluser] Controller Code: <?php So what has to go into the product() function? |