Hello and Help.
I have recently built an update page for my database. The problem is that i use dynamicaly built droplist. How can i change the below procedure so that it by default displays the relevent value of the row to be updated?
<?
function Dept_List(){
$Dept = 'Department';
$sql = mysql_query("SELECT Dept_Desc, Dept_Id FROM Departments");
echo "<select name=\"$Dept\">";
echo"<option> </option>";
while(list($Dept_Desc, $Dept_Id)=mysql_fetch_array($sql)){
$Dept_Desc = stripslashes($Dept_Desc);
echo "<option value=\"$Dept_Id\">$Dept_Desc</option>";
}
echo "</select>";
mysql_free_result($sql);
}
Cheers,
Lee.
Have dynamic drop list display a loaded value
Moderator: General Moderators
if a <option>-element has the attribute selected (or even better selected="true") it will be displayed as -hmmm- selected (in a one-row dropdown that's the visible entry)
i.e.
How to identify the record you have to mark with selected we don't know since you didn't give us the WHERE-clause of your update query 
i.e.
Code: Select all
<select name="s1">
<option>a</option>
<option>b</option>
<option selected="true">C</option>
<option>d</option>
</select>