Sorry to have to ask this, but I’ve been searching for quite some time, and am close to getting this to work but I just can’t do it. What I’m trying to do is new to me. hehe
I want to have a select statement in a form, with it’s options being populated by a field in a mysql table. I’m also going to have it check to see if one of the options should be selected, based on a field value in the form, and populate that option with a selected=”selected” attribute. Right now, it IS working, but I’m getting double options (2 options for every record in the mysql field).
Here is the code:
[code=php]
$officeresult = mysql_query(“SELECT `field` FROM `Table`”);
while ($row = mysql_fetch_array($officeresult)) {
$officename = $row[“field”];
foreach($row as $officevalue)
{
$officeselected = ($formItem == $officevalue) ? ‘ selected=”selected”‘ : “”;
echo “<option$officeselected>$officevalue</option>n”;
} }
like I said…it’s working “as intended,” but it’s creating double the options…