Jump to content

Variables in a select box?


Mr Chris

Recommended Posts

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

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.