yddib Posted September 10, 2008 Share Posted September 10, 2008 <select name="relationship" id="relationship" > <option value="Single" name="Single"<?php echo $row['relationship'] ==Single ? "selected=\"selected\"": "" ?>> Single </option> <option value="InaRelationship" name="InaRelationship"<?php echo $row['relationship'] ==InaRelationship ? "selected=\"selected\"": "" ?>> In a Relationship </option> <option value="Engaged" name="Engaged"<?php echo $row['relationship'] ==Engaged ? "selected=\"selected\"": "" ?>> Engaged </option> <option value="Married" name="Married"<?php echo $row['relationship'] ==Married ? "selected=\"selected\"": "" ?>> Married </option> <option value="Separated" name="Separated"<?php echo $row['relationship'] ==Separated ? "selected=\"selected\"": "" ?>> Separated </option> <option value="Divorced" name="Divorced"<?php echo $row['relationship'] ==Divorced ? "selected=\"selected\"": "" ?>> Divorced </option> </select> This drop down menu successfully sends its values to the database but it won't send "In a Relationship" (i.e. with the spaces) Above I have the code that works with no spaces between those words.....how can I put spaces between it so that when I take it out of the database it isn't all one word? Quote Link to comment https://forums.phpfreaks.com/topic/123589-solved-drop-down-menu-into-database/ Share on other sites More sharing options...
JonnoTheDev Posted September 10, 2008 Share Posted September 10, 2008 Change <option value="InaRelationship" name="InaRelationship"<?php echo $row['relationship'] ==InaRelationship ? "selected=\"selected\"": "" ?>> code] to [code]<option value="In a Relationship" name="InaRelationship"<?php echo $row['relationship'] ==InaRelationship ? "selected=\"selected\"": "" ?>> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/123589-solved-drop-down-menu-into-database/#findComment-638232 Share on other sites More sharing options...
yddib Posted September 10, 2008 Author Share Posted September 10, 2008 Thanks that works....just one new problem! It now doesn't come out of the database to my update form!! ??? So confused! Quote Link to comment https://forums.phpfreaks.com/topic/123589-solved-drop-down-menu-into-database/#findComment-638241 Share on other sites More sharing options...
BlueSkyIS Posted September 10, 2008 Share Posted September 10, 2008 2 things: 1. quote the value strings: <?php echo $row['relationship'] == 'Single' ? "selected=\"selected\"": "" ?> 2. add a space before selected: <?php echo $row['relationship'] == 'Single' ? " selected=\"selected\"": "" ?> Quote Link to comment https://forums.phpfreaks.com/topic/123589-solved-drop-down-menu-into-database/#findComment-638249 Share on other sites More sharing options...
yddib Posted September 10, 2008 Author Share Posted September 10, 2008 Oh brilliant thank you so much!! That's great! Working now! Quote Link to comment https://forums.phpfreaks.com/topic/123589-solved-drop-down-menu-into-database/#findComment-638261 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.