I am aware there are examples out there that hover around the issue of dynamically setting the selected tag in a HTML option tag, but I am hitting a pretty difficult issue of break statements and quotations in what I am trying to accomplish.
while($info = mysql_fetch_array($companydesc))
{
$output3 .= '<option value="'. $info['company_code'] . if ($result['company']==$info['description']){echo 'selected=\"selected\"'} . '">' . $info['description'] . '</option>';
}
echo $output3;
The error that I receive is a unexpected T_IF on the line with the if statement. Is it not legal to put an if statement in there? Or is it a matter of doing proper breaks? Any help would be greatly appreciated (and hopefully the formatting for the code worked)
$output3 .= '<option value="'. $info['company_code'] . (($result['company']==$info['description']) ? 'selected="selected"' : "") . $info['description'] . '</option>';