Use an editor with syntax highlighting and use php tags when posting php code on this board. Html tags for html code and code tags for any other code.
My recommendation is to not get in this position in the first place by being smart when chosing string delimiters, both concerning php and html. For example 'title="..."' or "title='...'" rather than 'title=\' ...\'', to minimize the need for escaping.
You might also want to have a look at heredoc and nowdoc.
onmouseover="this.style.backgroundColor=\'yellow\';"
But why not look at the end result yourself... It's often easier to spot the problem.
$t = '<tr style="width:100%; background-color:lightblue"
onMouseover="this.style.backgroundColor=\'yellow\';"
onMouseout="this.style.backgroundColor=\'lightblue\';"
title=\'Detaildaten von '.$result[0].' anzeigen\' onclick="window.location.href=\"userindex.php?action=profil&id='.$result[0].'\">';
echo htmlentities($t);