HTML PHP Presentation and Logic



I'm trying to keep presentation and logic seperate.
my application pulls out data from a MYSQL database and displays it on
a web page.

If there is a certain string in one of the displayed fields then I want
to output a whole load of html with a single php variable in the
middle, the obvious way to do this is to is to stack all the html in a
$variable, but then I am mixing up the presentation and logic. Any
suggestions

function($databasefieldcontent)
if (strpos($databasefieldcontent, 'needle')) {
$html="<a href=". <?echo $url?> . ">
<img height=22 alt="Awarding Body Information"
src="graphics/arrow_right.gif" width=30 border=0></a>"}
else {$html="";}
return $html;
}
end function

.