Passing multiple variables via url

Hi I’m trying to pass two variables via a url which I can acheive, but I’m having trouble extracting the information when the page refreshes.

This is the code I’ve used to pass the variables:-

[php]

<?php while ($row = mysql_fetch_assoc($result1)) { ?>

<?php echo $row['name']; ?>

<?php } ?>

[/php]

I’m able to acheive the my objective when one variable is passed using the following code:-

[php]

if (array_key_exists(‘gallery_id’, $_GET)) {

$gallery_id = $_GET[‘gallery_id’];

[/php]

My question is, how do I do this with two (or more) variables? I need to extract ‘year_id’ as well.

Thanks

you don’t need that array stuff, just do
[php]
$gallery_id = $_GET[‘gallery_id’];
$year_id = $_GET[‘year_id’];
[/php]

Thanks for the reply.

I’m trying to create a photo gallery that displays years at the top, the gallery names for the relevant year in the left hand pane and the relevant photos for a particular gallery in the right hand pane. I have nearly acheived the aim in that everything will initially display ok and when a different year is selected and the page reloads, it will list the galleries for that year and display the photos for the first gallery in the list.

The problem is that when a new gallery is selected I am able to pass the new gallery_id and the year_id when the page reloads, but I can’t extract both results using If(array_key_exists and since the script needs both to function I’m a bit stuck.

What i really want to do is something like
[php]

If(array_key_exists(‘year_id’, ‘gallery_id’, $_GET)) {
[/php]

but this won’t work! Is it possible to do it this way or am I barking up the wrong tree? How do I test if both values have been set?

Thanks.

take out that if statement and use

[php]
echo “

”;
print_r($_GET);
echo “
”;
[/php]

you’ll get somethig like
array(
[key] => value
)

Sponsor our Newsletter | Privacy Policy | Terms of Service