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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.