Click to See Complete Forum and Search --> : Passing variables in drop down lists using SSI


clive73
05-04-2005, 10:14 AM
Hello all,

Hopefully I'll explain this properly (and put in the correct forum)!

I have a series of drop down boxes (not the <select> type) that can drill down 3 levels. As they all use the last level I've included them in a seperate file and used SSI on the main page to include this file.

All works ok and the lists are displayed correctly, however I'm unable to get the options passed into the file so the correct page is called.

An example is below. The main headings are in bold, then the options below would be selected, and then below them are the options (showing different years) contained in the other file.

Sport
football
hockey

Cars
ford
renault

Beer
bud
fosters

So should the user go through the route of sports-football-2000, then it would redirect to:

mypage.php?option1=sports&option2=football&option3=2000

If only the options contained in the same file are used then I can get it to work by hardcoding, however by including the other file it means the url would have to be put in dynamically. I have tried using a onMouseOver and altering the menu file to php and attempting to extract the info but it didn't pick it up.

Please help!

thanks,

Clive.

SpectreReturns
05-05-2005, 12:00 AM
mypage.php?option1=sports&option2=football&option3=2000
Does that actually get passed in, or is that what you're trying to do? Because if it is, this is what you need:


$category = $_GET['option1'];
$option = $_GET['option2'];
$year = $_GET['option3']

clive73
05-05-2005, 04:45 AM
Thought I hadn't explained it properly!

As the user drills down through the menus, at the very last one it has a href of 'mypage.php?option1=sports&option2=football&option3=2000', so when clicked it goes to that page.

As there are so many options to hardcode would take forever, and why I was pointed in the direction of using SSI and having a file that contains the option 3 values. This is the last file that will be called, so the href would be embedded in there.

I was wondering if there's a way of passing the option 1 and 2 values from the main file into the file contain option 3. As there are no mouse clicks, simply the mouse hovering over the option, could they be picked up and passed?

Hope this explains it better - and thanks!

scragar
05-05-2005, 04:52 AM
you could put them in respective folders and go:

if(isset($_GET['option1'])){
if(isset($_GET['option2'])){
if(isset($_GET['option3'])){
if(!@include "MyIncludesFolder/".$_GET['option1']."/".$_GET['option2']."/".$_GET['option3'].".html"){
echo "page cannot be found";
};
}else{
if(!@include "MyIncludesFolder/".$_GET['option1']."/".$_GET['option2']."/index.html"){
echo "page cannot be found";
};
};
}else{
if(!@include "MyIncludesFolder/".$_GET['option1']."/index.html"){
echo "page cannot be found";
};
};
}else{
if(!@include "MyIncludesFolder/index.html"){?>
Main page content...
<?
};
};
?>

clive73
05-05-2005, 05:20 AM
Damn, my explanation is slightly wrong.

The main file contains a series of drop down boxes using <ul> and <li>. As you go down through each it presents another list of options depending on what you've selected. If I kept it all in the one file then I have it working, its just the duplication of code I'm concerned with.

The included file would always add the option 3 value to the url to be called. It's passing the option 1 and 2 values I'm struggling with.

The final called page is 'mypage.php?'. Added to this are option 1, 2 and 3, depending on the route through the lists the user takes. From the original posting, if they select sport then it becomes:

mypage.php?option1=sport&option2=whatever&option3=whatever

I could create the included menu file as php and use _GET to retrieve the values (as suggested) but as the mainfile is shtml will this make a difference, and how do I send the values without using _POST?

Thanks again.