Click to See Complete Forum and Search --> : [RESOLVED] "Drop-down Select Box" default value?


Shears
07-09-2006, 12:14 AM
I am not really sure if this is a php question. But if it is possible, i guess there will be some php in the solution.. Anyways. An update script that i have written is shown below. Is it possible to have the Drop-down Select Box thing default to a particular value (the value that is already in the database), not necessarily the value that is listed first?
<?
include("config.php");

mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

if ($id){
$query="SELECT * FROM members WHERE id='$id'";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

$i=0;
while ($i < $num) {

$koc_name=mysql_result($result,$i,"koc_name");
$dm_rank=mysql_result($result,$i,"dm_rank");
$stats=mysql_result($result,$i,"stats");

Echo"<form action='update2.php' method='post' >
<input type='hidden' name='id' value='$id'>
KoC Name: <input type='text' name='koc_name' value='$koc_name'><br>

Rank: <select name='dm_rank' size='1'>
<option value='Deranged'>Deranged</option>
<option value='Deviant'>Deviant</option>
<option value='Derilious'>Derilious</option>
<option value='Demented'>Demented</option>
<option value='Maniacal'>Maniacal</option>
</select><br>
Stats Link: <input type='text' name='stats' value='$stats'><br>
<input type='Submit' value='Update'>
</form>
</p>";

$i++;
}

} else { Echo "Error: No ID selected.";
}
?>
Hope you understand the question, and thank you

Shears :)

NogDog
07-09-2006, 12:17 AM
Take a look at this thread (http://www.webdeveloper.com/forum/showthread.php?t=112747) from a day or two ago.

Shears
07-17-2006, 01:29 PM
Thank you. That page was very useful. :)

Shears