Have dynamic drop list display a loaded value
Posted: Mon Oct 07, 2002 7:14 am
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.
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.