etsted Posted April 11, 2014 Share Posted April 11, 2014 this code generates unexpecteT_IF echo " <form> <select name='mnd'> <option value='jan'>jan</option> <option value='feb'>feb</option> <option value='mar'>mar</option> <option value='Apr' " . if($dagen_mnd == 'Apr'){echo "selected='selected'";} . ">Apr</option> </select> </form>"; Link to comment Share on other sites More sharing options...
justsomeguy Posted April 11, 2014 Share Posted April 11, 2014 An if statement does not belong inside an echo statement, an if statement does not return or evaluate to a value. echo " <form> <select name='mnd'> <option value='jan'>jan</option> <option value='feb'>feb</option> <option value='mar'>mar</option> <option value='Apr' " . ($dagen_mnd == 'Apr' ? 'selected="selected"' : '') . ">Apr</option> </select> </form>"; Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now