Mike088 Posted October 12, 2008 Share Posted October 12, 2008 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 Link to comment https://forums.phpfreaks.com/topic/128071-variable-with-multiple-values/ Share on other sites More sharing options...
MasterACE14 Posted October 12, 2008 Share Posted October 12, 2008 $this-> is used in object orientated programming, which unless your learning it in the moment, it would probably be best to avoid it for now. Link to comment https://forums.phpfreaks.com/topic/128071-variable-with-multiple-values/#findComment-663221 Share on other sites More sharing options...
JasonLewis Posted October 12, 2008 Share Posted October 12, 2008 $url = $_POST['website']; Of course it would need to be in a form and what-not. Look into forms. Or did I misunderstand you? Link to comment https://forums.phpfreaks.com/topic/128071-variable-with-multiple-values/#findComment-663226 Share on other sites More sharing options...
Mike088 Posted October 12, 2008 Author Share Posted October 12, 2008 $url = $_POST['website']; Of course it would need to be in a form and what-not. Look into forms. Or did I misunderstand you? Got it working, thanks mate Link to comment https://forums.phpfreaks.com/topic/128071-variable-with-multiple-values/#findComment-663229 Share on other sites More sharing options...
DamienRoche Posted October 12, 2008 Share Posted October 12, 2008 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. Link to comment https://forums.phpfreaks.com/topic/128071-variable-with-multiple-values/#findComment-663257 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.