Log In · Register

 
 
Closed TopicStart new topic
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?^
 
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
 
moorepocket
post May 14 2009, 09:08 PM
Post #3


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

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



i'll give it a tried.
 
Mikeplyts
post May 14 2009, 10:20 PM
Post #4


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

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



Oh, and btw, the code won't work unless you have a .php extenstion on your page. thumbsup.gif
 
moorepocket
post May 14 2009, 11:24 PM
Post #5


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

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



well i get that.

Do you know any other query string like this, but different?
 
Mikeplyts
post May 16 2009, 12:27 PM
Post #6


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

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



I'm not sure what you mean. Are talking about a different code, an easier method, how to create multiple varaibles?
 
moorepocket
post May 16 2009, 08:26 PM
Post #7


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

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



yeah. there is another code that i used to used. But i can't find it anymore. I think it has php include in the code for multiple pages.
 
juicyjoints
post May 23 2009, 12:50 PM
Post #8


Member
**

Group: Member
Posts: 10
Joined: May 2009
Member No: 729,459



Thanks Mikeplyts,

I was looking for this information for quite some time.

I m new here and impressed to find such a nice information so soon.

Thank you so much for great share.
 

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