Welcome Guest, Not a member yet? Register   Sign In
passing variable in URL
#1

[eluser]agubski[/eluser]
Hi,

I'm sure this is very stupid question, but I kind of shamefully stuck here.

I need to insert a variable $city into a Anchor tag and I getting all kind of errors.

here is the string

Code:
&lt;?=anchor('index.php?/display_add/details', '<img src="images/find.gif" border="0" alt="">');?&gt;

I need variable $city to be passed as a URI segment after /details...

Thanks

Alex
#2

[eluser]tonanbarbarian[/eluser]
this depends on how you get the data
if you use
Code:
$this->uri->segment(n);
Then something like this
Code:
&lt;?=anchor('index.php?/display_add/details/'.$city, '<img src="images/find.gif" border="0" alt="">');?&gt;

If like me you prefere to make an array of segments using
Code:
$this->uri->uri_to_assoc(n);
then you would use something like
Code:
&lt;?=anchor('index.php?/display_add/details/city/'.$city, '<img src="images/find.gif" border="0" alt="">');?&gt;
then
Code:
$segments = $this->uri->uri_to_assoc(3);
would produce
Code:
$segments[array]
(
  'city'=>xyz,
)
I prefer this because the segments can then be added in any order of matching pairs and the url still works
#3

[eluser]TWP Marketing[/eluser]
Assuming you have the value in the variable $city, then this should pass that value back as segment 5. Don't forget the slash after the function name "details".

Code:
&lt;?=anchor('index.php?/display_add/details/'.$city, '<img src="images/find.gif" border="0" alt="">');?&gt;
#4

[eluser]agubski[/eluser]
Thanks a lot,

little dot made all the difference Smile




Theme © iAndrew 2016 - Forum software by © MyBB