Well lets' see, we put aside the pointlessly redundant comments (since you've got div with perfectly good descriptive classes), the use of string addition instead of delimits on the echo, multiple echo for no reason, extra variable for nothing, procedural mysqli just to make it slower, img tag for what I'd probably have in the CSS with the 'online' status, putting tags into attributes where tags are invalid, wasting bandwidth using htmlentities instead of htmlspecialchars, paragraph around a non-paragraph element, strong on an element that probably doesn't/shouldn't need emphasis, title attribute on a IMG tag (which is most always pointless)...
You basically have definition list abuse too.
Code:
/*
Display Comments on Article.
*/
while ($stmt2->fetch()) {
echo '
<div class="post">
<div class="userInfo">
<a href="#" class="username online">
',htmlspecialchars($username),'
<b title="User is online">*<b></b></b>
<img src="/uploads/',htmlspecialchars($photoName),'"
width="100"
alt="Avatar: ',htmlspecialchars(
empty($photoLabel) ?
$username :
$photoLabel
),'"
class="avatar"
/>
</a><br />
<span>Joined:</span> 2/25/2012<br />
<span>Location:</span> Salt Lake City,UT<br />
<span>Posts:</span> 114
<!-- .userInfo --></div>
<div class="userComments">
<div>Posted on: ',date('Y-m-d g:ia',strtotime($createdOn)),'</div>
<p>
',nl2br(htmlspecialchars($comments)),'
</p>
<!-- .userComments --></div>
<!-- .post --></div>
<hr />';
}
Is probably how I'd approach that... Well, I'd probably have some code in there to try and detect <br><br> and turn them into </p><p> (regex most likely) -- though that's the type of conversion I'd probably do before storing it in mysql, that way you only need it once (twice if you allow edits) instead of wasting time doing it every time the page is displayed.
Bookmarks