By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

add parameter to all URLs

P: n/a


I am trying to make something similar to citysearch.com. For example:

If you search for a city, say Raleigh, NC, it will find it for you,
but then all other URLs on the page will have the location parameter
attached. For example, say "city=raleigh" So, if you go back to the
home page, or any other page on the site, that will still be attached to
the URL. Is there any easy way to do that? I know PHP has a way to
automatically attach a session ID to every URL.

Is there a way I can attach a parameter of my own choosing automatically?

I don't think cookies will work in this situation. The problem with
cookies is that there is only one cookie with one location in it, where
the user may have several pages open for different locations.

what do you think?
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Doug wrote:


I am trying to make something similar to citysearch.com. For example:

If you search for a city, say Raleigh, NC, it will find it for you,
but then all other URLs on the page will have the location parameter
attached. For example, say "city=raleigh" So, if you go back to the
home page, or any other page on the site, that will still be attached to
the URL. Is there any easy way to do that? I know PHP has a way to
automatically attach a session ID to every URL.

Is there a way I can attach a parameter of my own choosing automatically?

I don't think cookies will work in this situation. The problem with
cookies is that there is only one cookie with one location in it, where
the user may have several pages open for different locations.

what do you think?

Just a quick solution, write a little function like so:

<?php

function appendit() {
if(isset($_GET)) {
$message = '?';
foreach($_GET as $append_key => $append_val ) {
$message .= $append_key.'='.$append_val.'&';
}
}
return $message;
}
$urladdon = appendit();

echo '<a href="test.php'.$urladdon.'">Test Page</a>";
?>

Something like that should do the trick, there might be more automated
ways about, let the group know your findings.

Hope that helps,

Anthony.
Jul 17 '05 #2

P: n/a
"Doug" <do*****@XXXXremovetheXearthlink.net> wrote in message
news:lx*****************@newsread2.news.atl.earthl ink.net...


I am trying to make something similar to citysearch.com. For example:

If you search for a city, say Raleigh, NC, it will find it for you,
but then all other URLs on the page will have the location parameter
attached. For example, say "city=raleigh" So, if you go back to the
home page, or any other page on the site, that will still be attached to
the URL. Is there any easy way to do that? I know PHP has a way to
automatically attach a session ID to every URL.

Is there a way I can attach a parameter of my own choosing automatically?

I don't think cookies will work in this situation. The problem with
cookies is that there is only one cookie with one location in it, where
the user may have several pages open for different locations.

what do you think?


Go way to do this is to turn on output buffering then attach the parameters
to every hyperlink with help from regular expression. A manual search and
replace is probably best though--and probably quicker.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.