Jump to content

Recommended Posts

[!--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.
Link to comment
https://forums.phpfreaks.com/topic/4195-something-about-switch/#findComment-14590
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!
Link to comment
https://forums.phpfreaks.com/topic/4195-something-about-switch/#findComment-14592
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.