astonishin Posted July 31, 2011 Share Posted July 31, 2011 i have the code below i want to use the value of the slected one and echo it as $sex so i can insert it into my mysql database how can that be done. Quote Link to comment https://forums.phpfreaks.com/topic/243340-simple-question/ Share on other sites More sharing options...
astonishin Posted July 31, 2011 Author Share Posted July 31, 2011 Will it work like this? $gender = protect($_POST['gender']); <option <?php if($gender == "male") echo "selected"; ?> value="male">Male</option> Quote Link to comment https://forums.phpfreaks.com/topic/243340-simple-question/#findComment-1249626 Share on other sites More sharing options...
The Little Guy Posted July 31, 2011 Share Posted July 31, 2011 I am not sure what protect is, but that should work fine... have you tried it? Quote Link to comment https://forums.phpfreaks.com/topic/243340-simple-question/#findComment-1249702 Share on other sites More sharing options...
voip03 Posted July 31, 2011 Share Posted July 31, 2011 Remove one comments and test it. <html > <body> <? //$car='Saab'; $car='Audi'; ?> <select> <option>Volvo</option> <option>Saab</option> <option>Mercedes</option> <option <? if($car=='Audi'){ echo "selected='selected''"; }?> >Audi</option> </select> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/243340-simple-question/#findComment-1249714 Share on other sites More sharing options...
voip03 Posted July 31, 2011 Share Posted July 31, 2011 please mark as solved. the topic solved button can be found at the bottom left of the page Quote Link to comment https://forums.phpfreaks.com/topic/243340-simple-question/#findComment-1249790 Share on other sites More sharing options...
astonishin Posted July 31, 2011 Author Share Posted July 31, 2011 ty dude Quote Link to comment https://forums.phpfreaks.com/topic/243340-simple-question/#findComment-1249808 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.