Mr Chris Posted July 15, 2008 Share Posted July 15, 2008 Hi All, Looking for some help. I have a dropdown box which calls a value from a column called this_season in my database, and this value is 0809 which I save to a variable named $this_season Now, I also have declared a variable in my page named $currentSeason with the same value 0809 So using a dropdown menu I want to say if: $this_season=$currentSeason Effectively being... 0809=0809 Then make the value YES <select name="this_season" id="this_season"> <option value="<?php echo $currentSeason?>"<? if ($this_season == $currentSeason) echo ' selected' ?>>Yes</option> <option value=""<? if ($this_season != '$currentSeason') echo ' selected' ?>>No</option> </select> However, it does not output yes! and I know my two variables are being called as i've echoed them to the page. Any ideas where i'm going wrong? Thanks Link to comment https://forums.phpfreaks.com/topic/114858-variables-in-a-select-box/ Share on other sites More sharing options...
kenrbnsn Posted July 15, 2008 Share Posted July 15, 2008 Remove the single quotes around $currentSeason in this line: <option value=""<?php if ($this_season != '$currentSeason') echo ' selected' ?>>No</option> Ken Link to comment https://forums.phpfreaks.com/topic/114858-variables-in-a-select-box/#findComment-590646 Share on other sites More sharing options...
Mr Chris Posted July 15, 2008 Author Share Posted July 15, 2008 Thanks Ken, that's done it! Link to comment https://forums.phpfreaks.com/topic/114858-variables-in-a-select-box/#findComment-590654 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.