Jump to content


Photo

Something about SWITCH


  • Please log in to reply
2 replies to this topic

#1 genzoshen

genzoshen
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 06 March 2006 - 09:40 AM

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

#2 lessthanthree

lessthanthree
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts
  • LocationUK

Posted 06 March 2006 - 11:02 AM

[!--quoteo(post=352025:date=Mar 6 2006, 09:40 AM:name=Genzoshen)--][div class=\'quotetop\']QUOTE(Genzoshen @ Mar 6 2006, 09:40 AM) View Post[/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:

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");

    }
}

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:


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


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


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



Cheers
Phil.
call me a safe bet, i'm betting i'm not

#3 Guest_edwinsweep_*

Guest_edwinsweep_*
  • Guests

Posted 06 March 2006 - 11:04 AM

[!--quoteo(post=352025:date=Mar 6 2006, 10:40 AM:name=Genzoshen)--][div class=\'quotetop\']QUOTE(Genzoshen @ Mar 6 2006, 10:40 AM) View Post[/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
if (isset($_GET[action])){
//if true do this

}else{
//if not true do this

}
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!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users