I want to display a tag with a selected option, which would come from a database.
This is my code:
<?
function check($opt) {
if ($rows['fa'] = $opt) {
echo " selected='selected'";
}
}
echo $fa;
?>
<select name="opt" id="opt">
<option value="o1"<? check('o1'); ?>>Option1</option>
<option value="o2"<? check('o2'); ?>>Option2</option>
</select>
The problem is that the function doesn’t work with $rows[‘$fa’], and it works if I just type either “o1”, or “o2”.
If I echo $fa, it gives me the result (“o1″, or”o2”) from the database.
If the data of row is on $fa, set as global, please attention to the scope, the comparison (==):