Jump to content

.php?=


freaksville

Recommended Posts

Hey,

 

I'm a bit of a php n00b and was woundering if anyone could tell me how I can tell my php code to differ depending on what is at the end of the address.

 

(e.g. image.php and image.php?=blue)

 

The reason I want to know is that I have created a countdown to Christmas image (http://count.suprscribble.com/christmas/) and want people to be able to change the background colour depending on what extension of the address they use.

 

Thanks in Advance

Brad

Link to comment
https://forums.phpfreaks.com/topic/183314-php/
Share on other sites

switch($_GET['var']) {
        case 'x':
        // if you have ?var=x then the code here will run
    break;

        case 'abc':
        // if you have ?var=abc then the code here will run
    break;

        default:
        // The default is not required, but code here will run if all of the above case statements aren't matched
        // (ie var isnt x or abc in this case
    break;
}

You could also do the same with an if elseif and else statement

if($_GET['var'] == 'x') {
    // if you have ?var=x then the code here will run
}elseif($_GET['var'] == 'abc') {
     // if you have ?var=abc then the code here will run
}else{
    // Same as default above
}

 

Hope that gives you some help :)

Link to comment
https://forums.phpfreaks.com/topic/183314-php/#findComment-967615
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.