aebstract Posted January 25, 2010 Share Posted January 25, 2010 If I have something like: <option value=\"lalalla.html\">lalalla How can I run a simple if statement in it, roughly like: <option -if ( $var == $anothervar ) { SELECTED }- value=\"lalalla.html\">lalalla Link to comment https://forums.phpfreaks.com/topic/189792-if-statement-in-drop-down-option/ Share on other sites More sharing options...
schilly Posted January 25, 2010 Share Posted January 25, 2010 you basically got it: <option <?php if ( $var == $anothervar ) { echo "SELECTED=\"SELECTED\" } ?> value=\"lalalla.html\">lalalla Link to comment https://forums.phpfreaks.com/topic/189792-if-statement-in-drop-down-option/#findComment-1001569 Share on other sites More sharing options...
aebstract Posted January 25, 2010 Author Share Posted January 25, 2010 xD Thanks Link to comment https://forums.phpfreaks.com/topic/189792-if-statement-in-drop-down-option/#findComment-1001579 Share on other sites More sharing options...
schilly Posted January 25, 2010 Share Posted January 25, 2010 oops forgot semi colon <option <?php if ( $var == $anothervar ) { echo "SELECTED=\"SELECTED\"; } ?> value=\"lalalla.html\">lalalla Link to comment https://forums.phpfreaks.com/topic/189792-if-statement-in-drop-down-option/#findComment-1001581 Share on other sites More sharing options...
aebstract Posted January 25, 2010 Author Share Posted January 25, 2010 oops forgot semi colon <option <?php if ( $var == $anothervar ) { echo "SELECTED=\"SELECTED\"; } ?> value=\"lalalla.html\">lalalla <option <?php if ( $var == $anothervar ) { echo "SELECTED"; } ?> value=\"lalalla.html\">lalalla actually it'd be like that Just needed the basic though, was stupid to not think of it. Thanks! Link to comment https://forums.phpfreaks.com/topic/189792-if-statement-in-drop-down-option/#findComment-1001586 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.