pass multiple variables in URL?

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
User avatar
gregorious
Forum Commoner
Posts: 34
Joined: Wed Aug 23, 2006 9:55 am
Location: Orlando, FL

pass multiple variables in URL?

Post by gregorious »

This is probably a no brainer for most of you.

I know how to pass one variable through a url, but how do I pass multiple variables?

This is a no go.

[ <a href='edit_residential_image.php?id=$id;&imageid=$imageid'><strong>edit</strong></a> ]

I need to pass image ID and the residential ID.
Thanks in advance for any help.
User avatar
spamyboy
Forum Contributor
Posts: 266
Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius

Post by spamyboy »

Here you go:

Code: Select all

example.php?oneVariable=something&secondVariable=something&thinrdVariable=something
User avatar
webgroundz
Forum Commoner
Posts: 58
Joined: Thu Jun 21, 2007 1:20 am
Location: Philippines

Post by webgroundz »

here's another example :

i think you forgot to include the <?php ?> in your variable, it should be look like this:
instead of using = sign, you can use

Code: Select all

<?php echo $id; ?>
to print your variable.

<a href='edit_residential_image.php?
id =

Code: Select all

<?php =$id ?>
&imageid =

Code: Select all

<?php =$imageid ?>
'>redirect</a>


:wink: :) :D
User avatar
spamyboy
Forum Contributor
Posts: 266
Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius

Post by spamyboy »

or...

Code: Select all

<?=$var?>
User avatar
gregorious
Forum Commoner
Posts: 34
Joined: Wed Aug 23, 2006 9:55 am
Location: Orlando, FL

Thanks guys; that is a big help!

Post by gregorious »

Here is the fix for future readers!
I have been reading else where that "&" is better than "&".

Code: Select all

[ <a href='edit_residential_image.php?id=$id&imageid=$imageid'><strong>edit</strong></a> ]
Thanks guys; that is a big help!
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

spamyboy wrote:or...

Code: Select all

<?=$var?>
NO! NO NO NO NO NO!
Short tags == outdated? True.
:P
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

Re: Thanks guys; that is a big help!

Post by SidewinderX »

gregorious wrote:I have been reading else where that "&" is better than "&".
Care to elaborate why or post that source?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Thanks guys; that is a big help!

Post by superdezign »

SidewinderX wrote:
gregorious wrote:I have been reading else where that "&" is better than "&".
Care to elaborate why or post that source?
He is completely correct. & is the standard set by W3C. Don't believe me? Try to validate your HTML.
Post Reply