Jump to content


Photo

table...switch() idk


  • Please log in to reply
3 replies to this topic

#1 tgs

tgs
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 25 March 2006 - 10:07 AM

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.

#2 Gast

Gast
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts
  • LocationSouth East England

Posted 25 March 2006 - 06:19 PM

[!--quoteo(post=358182:date=Mar 25 2006, 10:07 AM:name=tgs)--][div class=\'quotetop\']QUOTE(tgs @ Mar 25 2006, 10:07 AM) View Post[/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:

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

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

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

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

}
?>

Hope that helps.
OS and Internet Specs:
Windows XP (with SP2), 1680x1050, PHP 4, MySQL 3, Internet Explorer 6 &7 /FireFox 2.0/Opera 9.2

Tutorials:
Simple Introduction to AJAX and XMLHttpRequest
Creating Live Data with AJAX Making a Google Suggest like application

#3 tgs

tgs
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 25 March 2006 - 06:40 PM

No that wasn't what I meant. I meant uhm...like using text links to run those.

#4 play_

play_
  • Staff Alumni
  • Advanced Member
  • 717 posts

Posted 25 March 2006 - 10:50 PM

[!--quoteo(post=358327:date=Mar 25 2006, 01:40 PM:name=tgs)--][div class=\'quotetop\']QUOTE(tgs @ Mar 25 2006, 01:40 PM) View Post[/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.

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

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

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

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

}
?>

then on the link, you'd have
echo '<a href="otherpage.php?id=1">click here to go to otherpage.php and do everything under case "1"</a>';

regex.kat.sh --- regex library
u.kat.sh ---- url shortener
tabbit.org ---- tabbed pastebin




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users