Page 1 of 1

How to obtain several variables from a URL?

Posted: Sat Aug 07, 2010 10:07 am
by db579
I'm using links like

Code: Select all

 href=?example=$example 
and the using GET to to obtain whether or not $example has been set by clicking the link and what it has been set as.

An example is:

Code: Select all

$album = (isset($_GET['album']) ? $_GET['album']:'');
	$Array = scandir("gallery");
					foreach($Array as $directory){
							echo "<a href='?album=$directory'>$directory</a>";					
					}
					?> 
How I do this for several variables in one link? Have tried googling but can't seem to find the right syntax anywhere. Thanks very much

Re: How to obtain several variables from a URL?

Posted: Sat Aug 07, 2010 12:44 pm
by Weirdan

Code: Select all

<a href="?var1=something&var2=somethingElse">click</a>

Code: Select all

<a href="?<?php echo http_build_query(array('var1' => 'something', 
                                            'var2' => 'somethingElse'), 
                                            '', '&')?>">click</a>

Re: How to obtain several variables from a URL?

Posted: Sat Aug 07, 2010 1:02 pm
by db579
Thank you very much! Was literally tearing my brains out over this but that works perfectly!