agge Posted April 3, 2007 Share Posted April 3, 2007 I have a dropdown menu like this one: <select name="country" tabindex="6" id="select_country"> <option value="">- Country List -</option> <?php $query = "SELECT * FROM country ORDER BY country ASC"; $result = mysql_query($query) or die('Error, query failed'); while ($row = mysql_fetch_array ($result)) { $country = $row['country']; ?> <option value="<?php echo $country ?>"><?php echo $country ?></option> After I have selected one country and I hit the submit button it go back to the default value in the box, what I want is to show the selected value in box until I selected another value. If the default value is Australia when I start this page, I then select USA and hit the submit button it reset to the default value "Australia", but I want it to show USA as long I not select anything else. I have tried to use session in selected="<?php echo $_SESSION['country']; ?>" but it didnt work. Anyone for a solution? Quote Link to comment https://forums.phpfreaks.com/topic/45469-solved-dropdown-menu/ Share on other sites More sharing options...
Trium918 Posted April 3, 2007 Share Posted April 3, 2007 Are you wanting something like this? Example: Click Here: Quote Link to comment https://forums.phpfreaks.com/topic/45469-solved-dropdown-menu/#findComment-220760 Share on other sites More sharing options...
churdaddy Posted April 3, 2007 Share Posted April 3, 2007 <select name="country" tabindex="6" id="select_country"> <option value="">- Country List -</option> <option value="<?php echo $_GET['country'] ?>"><?php echo $_GET['country'] ?></option> <?php $query = "SELECT * FROM country ORDER BY country ASC"; $result = mysql_query($query) or die('Error, query failed'); while ($row = mysql_fetch_array ($result)) { $country = $row['country']; ?> <option value="<?php echo $country ?>"><?php echo $country ?></option> How bout somethin like this Quote Link to comment https://forums.phpfreaks.com/topic/45469-solved-dropdown-menu/#findComment-220763 Share on other sites More sharing options...
agge Posted April 3, 2007 Author Share Posted April 3, 2007 None of your example did solve my question, BUT it helped me to find the solution to how I should do... So thanks.. <select name="country" tabindex="6" id="select_country"> <option value="">- Country List -</option> [b]<option value="<?php echo $_SESSION['country']; ?>" selected="<?php echo $_SESSION['country']; ?>"><?php echo $_SESSION['country']; ?></option>[/b] Quote Link to comment https://forums.phpfreaks.com/topic/45469-solved-dropdown-menu/#findComment-220832 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.