Welcome Guest, Not a member yet? Register   Sign In
Building Codeigniter URLs with variable segments
#5

[eluser]vikrantsharma1[/eluser]
[quote author="InsiteFX" date="1339286903"]
Code:
------------- Segments    1          2          3            4
http://www.mysite.com/[outlets]/[city_name]/[area_name]/[outlet_name].

// outlets controller
public function index()
{
    // NOTE: The second parameter 0 is a default value.
    $city_name   = $this->uri->segment(2, 0);
    $area_name   = $this->uri->segment(3, 0);
    $outlet_name = $this->uri->segment(4, 0);
}
[/quote]
Thanks for responding. Actually, I am new to this routes thing and pretty confused. As far as my understanding goes, the function that you have built will retrieve URI segments and based on that some results can be shown. My question is slightly different and let me try to explain it again.

Let's say I generate a list of all outlets with
Code:
$query = $this->db->select('outlet_name')->from('outlets')->limit(10, 0)
and then print them with a foreach loop with each outlet_name being a link to view details of the outlet.

Each of this link should look like http://www.mysite.com/[outlets]/[city_name]/[area_name]/[outlet_name]. My question is how do I generate such a link?


Messages In This Thread
Building Codeigniter URLs with variable segments - by El Forum - 06-09-2012, 12:56 PM
Building Codeigniter URLs with variable segments - by El Forum - 06-09-2012, 03:12 PM
Building Codeigniter URLs with variable segments - by El Forum - 06-09-2012, 04:50 PM
Building Codeigniter URLs with variable segments - by El Forum - 06-09-2012, 05:08 PM
Building Codeigniter URLs with variable segments - by El Forum - 06-10-2012, 02:45 AM
Building Codeigniter URLs with variable segments - by El Forum - 06-10-2012, 04:35 AM
Building Codeigniter URLs with variable segments - by El Forum - 06-10-2012, 11:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB