Here is the code I am testing for filling a Select list with values from a database.
$query = "SELECT name FROM department_table ORDER BY name";
$result = mysql_query($query) or die("Query Fialed");
while($data = mysql_fetch_array($result))
{
echo "<option value='" . $data['name'] . "'>" . $data['name'] . "</option>";
}
mysql_free_result($result);
This works all fine and dandy. But what I need now is to have one of those option values selected based on a value I have in Session. And I am kind of lost on how to do this. If someone could point me in the right direction, that would be great.
Thanks.