This is a discussion on add parameter to all URLs within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I am trying to make something similar to citysearch.com. For example: If you search for a city, say Raleigh, ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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? |
|
|||
|
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. |
|
|||
|
"Doug" <dougd99@XXXXremovetheXearthlink.net> wrote in message
news:lxDvd.3634$2J2.1035@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. |