Put while loop into a string
<p>I have this code that makes a string and then echos the loop out at the bottom.  The problem is only the last variable that was looped through will be displayed.  I want every iteration displayed.</p>

<pre><code>elseif ($row['type'] == 7) {
    $blog_table = $row['blog_table'];
    $getblog = mysql_query("SELECT * FROM `$blog_table`");

    while ($blog = mysql_fetch_assoc($getblog)) 
    {
        $rowID = $blog['postID'];
        $matches = mysql_query("SELECT * FROM content WHERE `id` = '$rowID' ORDER BY `id` DESC");
        while ($post = mysql_fetch_assoc($matches)) 
        {
            if (mysql_num_rows($matches) &gt; 0)
            {
            $strOutput = "&lt;div class=\"controlPanel\"&gt;&lt;a onClick=\"edit_{$post['id']}();return false\"&gt;&lt;div class=\"controlPanel_edit\"&gt;&lt;/div&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;p class=blogDate&gt;{$post['date']}&lt;/p&gt;&lt;span class=h1&gt;{$post['title']}&lt;p&gt;&lt;/p&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;{$post['maintext']}&lt;p&gt;&lt;/p&gt;";
            $postID = $post['id'];
            $getcomments = mysql_query("SELECT * FROM content WHERE `postID` = '$postID' ORDER BY `id` DESC");
            $num_comments = mysql_num_rows($getcomments); 
            $strOutput = $strOutput."&lt;p class=\"blogPublisher\"&gt;Posted by {$post['publisher']}  |  Comments ({$num_comments})&lt;/p&gt;";

            $strOutput = $strOutput."&lt;div class=\"heriyah_blog_comments_content\"&gt;";
            while ($comments = mysql_fetch_assoc($getcomments)) 
            {
            $strOutput = $strOutput."&lt;span class=\"blogCommentPublisher\"&gt;&lt;b&gt;{$comments['publisher']}&lt;/b&gt;  |  {$comments['date']}&lt;a onClick=delete_{$row['id']}();return false&gt;&lt;img src=admin/system/images/delete.jpg class=click_btn&gt;&lt;/a&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;{$comments['maintext']}&lt;p&gt;&lt;/p&gt;";
            }
            $strOutput = $strOutput."&lt;/div&gt;";
            $strOutput = $strOutput."&lt;a class=click_btn onClick=comment_{$post['id']}();return false&gt;Post a Comment&lt;/a&gt;&lt;hr&gt;&lt;/hr&gt;";
            }
            $strOutput = $strOutput;
        }
    }
    echo "$('#{$row['div']}.heriyah').append('&lt;div class=\"heriyah_sortable\" id=\"sort_{$row['id']}\"&gt;&lt;div class=\"controlPanel\"&gt;&lt;a onClick=\"blog_{$row['blogID']}();return false\"&gt;&lt;div class=\"controlPanel_settings\"&gt;&lt;/div&gt;&lt;/a&gt;&lt;a onClick=\"delete_{$row['id']}();return false\"&gt;&lt;div class=\"controlPanel_delete\"&gt;&lt;/div&gt;&lt;/a&gt;&lt;div class=\"controlPanel_move\"&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;{$strOutput}&lt;/div&gt;');\n";
}
</code></pre>
