Hi skyloon,
as I understood ur requirement, it is to show existing values for the current user.
Following is the code, which I used for country in my form.
"$country_id_v" is the retrieved value for country ID of current user. The corresponding country name I am getting by query.
$country_query = "SELECT country_description FROM country_m WHERE country_id = $country_id_v";
$country_result = mysql_query($country_query) or die ("SELECT Failed.");
$country_row = mysql_fetch_array($country_result);
$country_description_v = $country_row[country_description];
<TR> <TD NOWRAP align=middle class=text> Country : </TD>
<TD align=left cellspacing="5"> <SELECT NAME="country_id_array">';
/ Build the list of country_id's here, so that it can be displayed in the list-box. /
$query = "SELECT * FROM country_m ORDER BY country_description";
$result = mysql_query($query) or die ("SELECT FaileD.");
/ The following list item is added to have current value of the country_id which is obtained from the database. This will be the very first choice, and will get used when the user does not want to modify/change the value of country_id. /
echo' <OPTION value='.$country_id_v .' >
'.$country_description_v.'
</OPTION> ';
/ Append countries present in the country_m below the current value. /
while ($list = mysql_fetch_array($result))
{
if($list[country_id] != $country_id_v)
{
echo '
<OPTION value='. $list[country_id] .'>
'.$list[country_description].'
</OPTION>' ;
}
}
echo '
</SELECT>
</TD>
</TR>
I hope this will help u.