Hello all,

Im trying to create a page that will display content based off of the variable join- in the URL

for instance

we have a page called join.php. its just a Template file with no content in it.

i want to display the content by using a varibale

so if the URL variable of join=1 i wanna drop join1.html into that page tempate and if its join=2 i wanna display join2.html in that template.

iv seen referances to this

<php
$join_code = $_request["join"];
if($join_code == 1) {
OPTION 1
}... and so on

but not sure if thats what i need to how to implement it.

can some one please help

thank you
Steve

    The way I do it look quiet like yours.

    I always pass a variable like you (ex. index.php?id=1). The only difference is that I use $_GET["id"] to get the page.

    Than, I use a switch case

    switch($_GET["id"]);
    {
     case "1":
       include("page1.html");
     break;
     case ...
    }
    
    

      Originally posted by daok
      The way I do it look quiet like yours.

      I always pass a variable like you (ex. index.php?id=1). The only difference is that I use $_GET["id"] to get the page.

      Than, I use a switch case

      switch($_GET["id"]);
      {
       case "1":
         include("page1.html");
       break;
       case ...
      }
      
      

      [/B]

      Hello thank you for your reply. i see your coding but how woud i have a #2 set like case "2";?

        Originally posted by remixer
        Hello thank you for your reply. i see your coding but how woud i have a #2 set like case "2";?

        not sure if are asking the if your test case was an actual "#2" or just a second case....but here they both are...

        switch($_GET["id"])
        {
         case "1":
           include("page1.html");
         break;
         case "#2":
           include("page2.html");
          break;
        }
        

        or if you were just wondering how to do the second case statement:

        switch($_GET["id"])
        {
         case "1":
           include("page1.html");
         break;
         case "2":
           include("page2.html");
          break;
        }
        

        should work...

          Originally posted by daok
          The way I do it look quiet like yours.

          I always pass a variable like you (ex. index.php?id=1). The only difference is that I use $_GET["id"] to get the page.

          Than, I use a switch case

          switch($_GET["id"]);
          {
           case "1":
             include("page1.html");
           break;
           case ...
          }
          
          

          [/B]

          One edit to the code. I don't think you need the ";" after the swtich($GET["id"])

            Originally posted by noimad1
            One edit to the code. I don't think you need the ";" after the swtich($GET["id"])

            no need the ";" sorry 😉

              Thank you Very much, that worked Great!

              Steve

                OK, I know that working through the switch issue is resolved, but I got here late, and wanted to throw this into the ring... It sounds like your case compares match the page numbers of your files anyhow, so you really wouldn't need a switch/case set anyhow.

                All you would need to do is this:

                IF(file_exists("page".$_GET['id'].".html")){
                   include("page".$_GET['id'].".html");
                } else {
                   echo "page".$_GET['id'].".html does not exist!";
                }
                
                  Write a Reply...