Jump to content

table...switch() idk


tgs

Recommended Posts

Okay, I have a switch() set up...kind of...in a table. Anyway, I can get the defualt done (not that difficult)
Now...my problem. coding my links so that open the different files in the switch.
Thanks, hope that explains it well enough.
Link to comment
Share on other sites

[!--quoteo(post=358182:date=Mar 25 2006, 10:07 AM:name=tgs)--][div class=\'quotetop\']QUOTE(tgs @ Mar 25 2006, 10:07 AM) [snapback]358182[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Okay, I have a switch() set up...kind of...in a table. Anyway, I can get the defualt done (not that difficult)
Now...my problem. coding my links so that open the different files in the switch.
Thanks, hope that explains it well enough.
[/quote]


Well I don't know exactly if this is exactly what you mean, but the easiest way is to use $_GET. Say if you have a page that is called "example.php" and you want to have 5 different sections to that page, you could have "example.php?id=1", "example.php?id=2", "example.php?id=3" and so on...

To do this and include a relevant file have this:

[code]<?php
switch($_GET['id']) {

default :
    include("defaultpage.php");
    break;

case "1" :
    include("page1.php");
    break;    

case "2" :
    include("page2.php");
    break;    

}
?>[/code]

Hope that helps.
Link to comment
Share on other sites

[!--quoteo(post=358327:date=Mar 25 2006, 01:40 PM:name=tgs)--][div class=\'quotetop\']QUOTE(tgs @ Mar 25 2006, 01:40 PM) [snapback]358327[/snapback][/div][div class=\'quotemain\'][!--quotec--]
No that wasn't what I meant. I meant uhm...like using text links to run those.
[/quote]


Yes, the code the other person posted will work.

[code]
<?php
switch($_GET['id']) {

default :
    include("defaultpage.php");
    break;

case "1" :
    include("page1.php");
    break;    

case "2" :
    include("page2.php");
    break;    

}
?>
[/code]

then on the link, you'd have
[code]echo '<a href="otherpage.php?id=1">click here to go to otherpage.php and do everything under case "1"</a>';[/code]
Link to comment
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.