Hi I have a Dragonfly site which i've been modding up, but i am a complete beginner with Php... Found a similar issue on the Dragonfly forums here, but it doesn't cover my problem and the boards there are all locked

There is a center block i have showing up on the main page that normally lists the most recent blog posts. I've added the blog author into this without a problem, but i want to add some info after the title link, that tells you how many comments have been made on that blog entry.

I've managed to get the first line working, but although it counts the comments correctly, it screws with the rest of the info.
eg:
author > title link, no. of comments (works fine on line 1, but then....)
3 > author linking to correct blog, no. of comments
2 > random username-but linking to correct blog, no. of comments


have probably gone a real long winded way about this, lol, but I have no idea what i'm doing wrong, just don't know enough about the syntax etc (only really done html and css properly, just dabbled in perl)
Would really appreciate any help or tips.


So... if anybody has afew minutes to spare here's the code ...

original section:
PHP Code:
$result $db->sql_query("SELECT id, aid, title, timestamp FROM ".$prefix."_blogs WHERE private='0' OR aid='".$userinfo['username']."' ORDER BY timestamp DESC LIMIT $entries");
if (
$db->sql_numrows($result)) {    
    while (list(
$blog_id$blog_author$blog_title$blog_timestamp) = $db->sql_fetchrow($result)) {
        
$content .= '<a title="'.formatDateTime($blog_timestamp_DATESTRING2).'" href="'.getlink('Blogs&amp;mode=display&amp;id='.$blog_id).'"><img src="images/arrow.gif" alt="'.formatDateTime($blog_timestamp_DATESTRING2).'" border="0" /> '.$blog_title.'</a> ';
       }
    
$content .= '</div>';

and this is what i changed it to...
PHP Code:
$result $db->sql_query("SELECT id, aid, title, timestamp FROM          ".$prefix."_blogs WHERE private='0' OR aid='".$userinfo['username']."' 
ORDER BY timestamp DESC LIMIT 
$entries");
if (
$db->sql_numrows($result)) {    
    while (list(
$blog_id$blog_author$blog_title$blog_timestamp) = $db->sql_fetchrow($result)) {
        
$content .= '<b>'.$blog_author.'</b> <a title="'.formatDateTime($blog_timestamp_DATESTRING2).'" href="'.getlink('Blogs&amp;mode=display&amp;id='.$blog_id).'"><img src="images/arrow.gif" alt="'.formatDateTime($blog_timestamp_DATESTRING2).'" border="0" /> '.$blog_title.'</a> ';

/*** bit i've added to calculate comments ******/        
            
$result $db->sql_query("SELECT * FROM ".$prefix."_blogs_comments WHERE bid='$blog_id' ORDER BY timestamp ASC");
            
$blog_comments $db->sql_numrows($result);
            
$content .= '&nbsp;&nbsp;&nbsp;'.(($_GET['comments'] == 'show') ? '<b>'._B_COMMENTS_HIDE.'</b>' '<b>'._B_COMMENTS.' ('.$blog_comments.')</b>').'<br />';
/***** end *******/

       
}
    
$content .= '</div>';

Any ideas?