On 18 May 2004 09:06, Brent Clark wrote: > Hi all > > For the likes of me I cant seem to figure out how to have a > select drop down > box , and have it so, that when I click the submit button, > the page displays > the correct content (which is what it does) but at the same > time I need the > select box to be at the option of the query. > > Below is part of my code. > > If someone could help, it would be most appreciated. > > <select name="uname"> > <?php > $sqlu="SELECT id,user,name FROM users > ORDER BY user > ASC"; > $name_result = mysql_query($sqlu); > while($rowu=mysql_fetch_array($name_result)){ > echo"<option > value=\"$rowu[user]\">$rowu[user]</option>\n"; > } > > > </select>
Assuming that this form submits to itself, so $_POST['uname'] will be set to the selected value: $selected = @$_POST['uname']; while($rowu=mysql_fetch_array($name_result)){ echo "<option value=\"$rowu[user]\""; if ($selected==$rowu['user']) echo ' selected'; echo "$rowu[user]</option>\n"; } Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php