Log In · Register

 
php include
moorepocket
post May 14 2009, 05:26 PM
Post #1


Death is a promise given to us at birth
*******

Group: Official Designer
Posts: 4,757
Joined: Mar 2004
Member No: 7,459



does anyone know the script to php include? I don't mean the regular kind.

QUOTE


something like that?^
 
 
Start new topic
Replies
Mikeplyts
post May 14 2009, 06:07 PM
Post #2


Mel Blanc was allergic to carrots.
*******

Group: Official Designer
Posts: 6,371
Joined: Aug 2008
Member No: 676,291



It's called a Query string. The code is pretty simple if you use the GET function. Try this code.

CODE
<?php
    if ( isset( $_GET['VARIABLE'] ) ){
        $page = $_GET['VARIABLE'];
    }
    if ( empty( $VARIABLE ) || $VARIABLE == '' || $VARIABLE == '0' ){
        echo "This is the default content. (i.e. - Home Page content)";
    } else if ( $VARIABLE == 'VALUE1' ){
        echo "This is the content of this value or it could also be the default content. (i.e. - Page 1 content)";
    } else if ( $VARIABLE == 'VALUE2' ){
        echo "This is the content of this value. (i.e. - Page 2 content)";
    } else {
        echo "Error page here.";
    }    
?>


1.) Replace VARIABLE with the name of the varible you want to use, i.e. - "page".

2.) Replace VALUE1 with the value of your choice so that it'll show up as http://www.example.com/path/to/file.php?VARIABLE=VALUE#1.

3.) Repeat step 2 for VALUE2.

4.) Now replace the fillers for each value.

5.) (Optional:) If you want to add more than 2 values and what not, then just repeat this part of the code and edit it accordingly.
CODE
else if ( $VARIABLE == 'VALUE' ){
        echo "This is the content of this value.";
    }


That's pretty much it. I'm not sure though how to add different variables but you could doing the same technique in step 5 except you replace both the variable and the value. If you want to see it in action, go here.

Good Luck. thumbsup.gif
 

Posts in this topic


Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: