Jump to content

Archived

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

tgs

table...switch() idk

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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
No that wasn't what I meant. I meant uhm...like using text links to run those.

Share this post


Link to post
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]

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.