session in a link or database?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
textahead
Forum Newbie
Posts: 4
Joined: Sat Mar 07, 2009 10:43 pm

session in a link or database?

Post by textahead »

Heres a curly one for yous.
I have about 20 links on a page that I need to have a variable associated with it
Ie: if you click on the link

Code: Select all

<a href=USA.php>NEW YORK</A>
it will take you to USA.php but display the city of New York at the top of the page. the next link would be

Code: Select all

<a href=USA.php>Detroit</A>
this would also take you to the USA.php but would display Detroit at the top of the page and so on
The way I imagine this would work is by something like this

Code: Select all

<a href=USA.php<?php[$USA=New York]?> New York </a>
<a href=USA.php<?php[$USA=Detroit]?> Detroit</a>
i would then have to pass the variable $USA to a session so that it carrys to the next page and is displayed.

Am I on the right track or is there a better way of doing this?

I would also like other things to change not just the name at the top but If i can figure out how to carry a different value for one of 20 or so links/variable across to one page I think I could work the rest out.
Cheers in advance
Reviresco
Forum Contributor
Posts: 172
Joined: Tue Feb 19, 2008 4:18 pm
Location: Milwaukee

Re: session in a link or database?

Post by Reviresco »

Code: Select all

<a href="USA.php?city=new_york">NEW YORK</a>
<a href="USA.php?city=detroit">DETROIT</a>
<a href="USA.php?city=chicago">CHICAGO</a>
Post Reply