Jump to content


Fetch id from url

id url

  • Please log in to reply
4 replies to this topic

#1 abhishek

abhishek

    Member

  • Members
  • PipPip
  • 10 posts

Posted 09 May 2013 - 01:48 PM

Hi All

 

I want to fetch id from the url.

 

URL:- http://localhost/pro...ts/index/edit/3

I have tried:-

        $update_url = $_SERVER['REQUEST_URI'];
        $path = parse_url($update_url, PHP_URL_PATH);
        $pathComponents = explode("/", trim($path, "/"));
        $ID = $pathComponents[7];

 

It is working fine but when i upload my project on live site, i have  to change the component number everytime and in every controller as there is difference in no. of components.

So, I want to know if there is any other method to fetch to do so..?

 

 

Thanks in advance.



#2 sachin vairagi

sachin vairagi

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts

Posted 09 May 2013 - 01:52 PM

abhishek from ideal???



#3 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 09 May 2013 - 02:58 PM

it is answered here: http://www.grocerycr...ting/#entry7286


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#4 abhishek

abhishek

    Member

  • Members
  • PipPip
  • 10 posts

Posted 10 May 2013 - 05:04 AM

@davidoster,

I dint get how will i fetch id from the  answer mentioned in

http://www.grocerycr...ting/#entry7286

 

I just  want to fetch id from the url

My url looks like:

http://localhost/pro...ts/home/edit/27



#5 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 10 May 2013 - 05:28 AM

$id = $this->uri->segment(3);


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr






Also tagged with one or more of these keywords: id, url

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users