scrubbicus Posted December 12, 2009 Share Posted December 12, 2009 $selected = ( $select_value ) ? ( ($row['id'] == $select_value) ? 'selected' : ' ' ) : ' '; I suppose it is since I'm not getting an error but I don't believe it's doing what I think it should do. I want to set $selected depending on if $select_value is TRUE or FALSE, if it is TRUE I want to then check if it's the same as the row id we're currently in with the SQL loop, if it is, set it to 'selected' if not then nothing. Link to comment https://forums.phpfreaks.com/topic/184865-is-this-short-form-if-else-valid/ Share on other sites More sharing options...
sKunKbad Posted December 12, 2009 Share Posted December 12, 2009 Even if it does work, you should rewrite it to be more clear for maintenance and maintainability. Come back to something like that after 6 months and see how easy it is to figure out what you were doing. Link to comment https://forums.phpfreaks.com/topic/184865-is-this-short-form-if-else-valid/#findComment-975853 Share on other sites More sharing options...
ngreenwood6 Posted December 12, 2009 Share Posted December 12, 2009 should look like this: $selected = ($row['id'] == $select_value) ? 'selected' : ''; Link to comment https://forums.phpfreaks.com/topic/184865-is-this-short-form-if-else-valid/#findComment-975854 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.