Jump to content

Archived

This topic is now archived and is closed to further replies.

genzoshen

Something about SWITCH

Recommended Posts

I want to use SWITCH for a site navigation. something like this

[a href=\"http://www.aerogaming.net\" target=\"_blank\"]aerogaming.net[/a]

they used "?action=" how do I get started? thanks

Share this post


Link to post
Share on other sites
[!--quoteo(post=352025:date=Mar 6 2006, 09:40 AM:name=Genzoshen)--][div class=\'quotetop\']QUOTE(Genzoshen @ Mar 6 2006, 09:40 AM) [snapback]352025[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I want to use SWITCH for a site navigation. something like this

[a href=\"http://www.aerogaming.net\" target=\"_blank\"]aerogaming.net[/a]

they used "?action=" how do I get started? thanks
[/quote]

From looking at the site I presume they have a file called index.php that contains the entire layout of the site. Then somewhere in the body they have a statement like below:

[code]
if (isset($_GET["action"])
{
    switch($_GET["action"])
    {
     case("page1"):
          require_once("page1.php");
     break;

     case("page2"):
          require_once("page2.php");
     break;

     //etc

     default: require_once("mainpage.php");

    }
}
[/code]

of course you can substitute the page names and pages for whatever you desire to use.


To initialize the $_GET["action"] variable you need to make your site navigation like the following:

[code]

<a href='index.php?action=page1'>Page 1 </a>
<a href='index.php?action=page2'>Page 2 </a>

[/code]

or if you don't want to use index.php? the following can be used

[code]

<a href='?action=page1'>Page 1</a>
<a href='?action=page2'>Page 2</a>

[/code]


Cheers
Phil.

Share this post


Link to post
Share on other sites
Guest edwinsweep
[!--quoteo(post=352025:date=Mar 6 2006, 10:40 AM:name=Genzoshen)--][div class=\'quotetop\']QUOTE(Genzoshen @ Mar 6 2006, 10:40 AM) [snapback]352025[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I want to use SWITCH for a site navigation. something like this

[a href=\"http://www.aerogaming.net\" target=\"_blank\"]aerogaming.net[/a]

they used "?action=" how do I get started? thanks
[/quote]

the "?action=" behind a url like this "index.php?action=logout"
thats a value you will pass on to the next page trough the $_GET command
if the index.php page that you can see in the link contains the following code
[code]
if (isset($_GET[action])){
//if true do this

}else{
//if not true do this

}
[/code]
it will check to see if the variable is indeed passed on and based on that it will create the rest of the page!
for more info you should search the net for lessons about variables, and passing on variables to other pages!
there are enough tutorials on the internet to learn this concept in only a few minutes.
[a href=\"http://www.tizag.com\" target=\"_blank\"]http://www.tizag.com[/a] is a pretty good one i think.
good luck!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.