Cetanu Posted July 5, 2009 Share Posted July 5, 2009 I have a form that is giving me a tiny problem. I have this: <label for="rating">I Rate Mythscape...</label> <select id="rating" name="rating" value="<?php echo $row['rating']; ?>"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option></select> When someone edits their profile, it is supposed to automatically have a value of $row['rating'], which would be what they posted into the DB. However, when they edit their profile it always goes back to having a value of 1....how can I make it so that they do not need to physically change that field every time they edit? ??? Quote Link to comment https://forums.phpfreaks.com/topic/164807-solved-form-w-php-small-problem/ Share on other sites More sharing options...
trq Posted July 5, 2009 Share Posted July 5, 2009 <label for="rating">I Rate Mythscape</label> <select id="rating" name="rating"> <option value="1"<?php echo $row['rating'] == 1 ? ' selected="selected"' : ''; ?>>1</option> <option value="2"<?php echo $row['rating'] == 2 ? ' selected="selected"' : ''; ?>>2</option> <option value="3"<?php echo $row['rating'] == 3 ? ' selected="selected"' : ''; ?>>3</option> <option value="4"<?php echo $row['rating'] == 4 ? ' selected="selected"' : ''; ?>>4</option> <option value="5"<?php echo $row['rating'] == 5 ? ' selected="selected"' : ''; ?>>5</option> </select> Quote Link to comment https://forums.phpfreaks.com/topic/164807-solved-form-w-php-small-problem/#findComment-869058 Share on other sites More sharing options...
Cetanu Posted July 5, 2009 Author Share Posted July 5, 2009 Thanks a bunch! Quote Link to comment https://forums.phpfreaks.com/topic/164807-solved-form-w-php-small-problem/#findComment-869061 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.