Results 1 to 5 of 5

Thread: include variable

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139

    include variable

    this is a real dum question but I have a page called page.php now this is my template and has links to all other sections on the site. The links are page.php?ID=5 (or whatever)

    In the middle of the page I want to add a include script which will allow whatever the ID is to be displayed.. can anyone help me with this?

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    What is the name of the files to be included, and what are their relation to the ID?

    If they have the ID number in them, you can do something like:

    Code:
    include ('page' . $ID . '.php');
    If you have certain IDs that stand for certain page names, you could do a case statement:

    Code:
    switch ($ID) {
        case 0:
            include 'this_page.php'; break;
        case 1:
            include 'that_page.php'; break;
        case 2:
            include 'other_page.php'; break;
        default:
            die('Invalid ID specified.');
    }
    Is this what you're looking for?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139
    Originally posted by The Hobo
    What is the name of the files to be included, and what are their relation to the ID?

    If they have the ID number in them, you can do something like:

    Code:
    include ('page' . $ID . '.php');
    If you have certain IDs that stand for certain page names, you could do a case statement:

    Code:
    switch ($ID) {
        case 0:
            include 'this_page.php'; break;
        case 1:
            include 'that_page.php'; break;
        case 2:
            include 'other_page.php'; break;
        default:
            die('Invalid ID specified.');
    }
    Is this what you're looking for?
    well it's a plain txt page which is kept in a folder... something like test1.php and test2.php then menu on my template have all the links which will be page.php?ID=whatever... in the page.php i have a include script which is fine if was just test1.php just it can change to all of the test1.php and test2.php depends on what page was loaded

  4. #4
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    I'm pretty sure he answered your question. You should only be putting the above switch statement or the simple include into your php file with nothing else if you just want to display the contents of the other file.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  5. #5
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by kiwis
    well it's a plain txt page which is kept in a folder... something like test1.php and test2.php then menu on my template have all the links which will be page.php?ID=whatever... in the page.php i have a include script which is fine if was just test1.php just it can change to all of the test1.php and test2.php depends on what page was loaded
    Like ober said, I pretty much answered your question, then.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width