php variables in url link

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
midohioit
Forum Newbie
Posts: 18
Joined: Tue Dec 05, 2006 10:19 am

php variables in url link

Post by midohioit »

I know you can do one variable in a link like the following:

<a href="test.php?variable1=xyx">link to other page</a>

is there a way to do more then one variable? so i also want to do variable2 ...
dimxasnewfrozen
Forum Commoner
Posts: 84
Joined: Fri Oct 30, 2009 1:21 pm

Re: php variables in url link

Post by dimxasnewfrozen »

One way is:

<a href="test.php?variable1=" . $var1 ."&variable2=" . $var2 .">link to other page</a>

All you have to do is add the & in between each variable you're assigning
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: php variables in url link

Post by josh »

User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: php variables in url link

Post by AbraCadaver »

If you want your page to validate you'll need to use & instead of & regardless.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
midohioit
Forum Newbie
Posts: 18
Joined: Tue Dec 05, 2006 10:19 am

Re: php variables in url link

Post by midohioit »

AbraCadaver and others thank you. That fixed my problem. I could not use sessions I had to do it with url because the client wanted to bookmark the page and be able to send it to others. if i did it with sessions then it would not have stored info in a helpful way for this. The issue was solved with your help. I appriciate your feedback.
midohioit
Forum Newbie
Posts: 18
Joined: Tue Dec 05, 2006 10:19 am

Re: php variables in url link

Post by midohioit »

how do you mark this post as "solved" ?
Post Reply