Hi all,
PHP Code:
<select name="comp" id="comp" style="width:130px;">
<?php $sqlcomp = mysql_query("SELECT * FROM comp");
while ($redcomp = mysql_fetch_array($sqlcomp)) {
extract($redcomp);
echo "<option value=\"$comp_id\">comp_name</option>";
}
?>
</select>
My question is following, I have $_SESSION['comp_id'] equals some value, now I'd like to make 1st option in the list the one I'm having stored in session.
Ex :
Results from database are :
comp_id comp_name
1 comp1
2 comp2
3 comp3
and in session I have stored $_SESSION['comp_id'] equals 2 ; now I'd like to get the following result in html from php :
[code=text]
<select name="comp" id="comp" style="width:130px;">
<option value="2">comp2</option>
<option value="1">comp1</option>
<option value="3">comp3</option>
</select>
[/code]
OR
[code=text]
<select name="comp" id="comp" style="width:130px;">
<option value="2">comp2</option>
<option value="3">comp1</option>
<option value="1">comp3</option>
</select>
[/code]
it really doesn't matter as long as item from session is located 1st on the list. Thank you and I apologize for my bad English.