Look,
you have a dbtable and there's a field which contains the index of category selected.
You retrieve it through mysql query or whatever:
$r = mysql_query("select cat_num from dbtable where id = $id);
then you assign that value to $selected :
$selected = mysql_result($r, 0);
and then everything in the way i described before.
Be aware that 'selected' in echo ' selected' isn't a variable and hasn't much to do with $selected. It's just html keyword that scrolls the dropdown list to the needed position.
Clear enough?