Jump to content

Variable with multiple values?


Mike088

Recommended Posts

Hey all, got myself in a little pickle (keep in mind I am relatively new to PHP lol). So I have a HTML selection box with some values now I want to then use what the user selected within a variable later on. So here I have the selection box code:

<select name="website">
<option value="100-01">Url1</option>
<option value="100-02">Url2</option>

 

And now I want what is selected into a variable called $url so umm:

 

$url = '';

 

To do this I think I need something like:

 

if option with value 100-01 is selected then $url = url1

else if option with value 100-02 is selected then $url = url2

 

I read something about using $this-> but I'm not sure... so how would I go about making the above work lol?

 

Cheers, Mike 8)

Link to comment
https://forums.phpfreaks.com/topic/128071-variable-with-multiple-values/
Share on other sites

Hey Mike, not sure if you got it working - with the other thread - but here's how it should be:

 

if ($url==100-01) {$result = headache;}
if ($url==100-02) {$result = biggerheadache;}

 

No need for the 'if else' in this instance. Hope that helps.

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.