remove duplicate columns being printed in a loop
<p>I am using the code below to print from an array but its printing too many of the columns because i am using a foreach loop...</p>

<p>How can i print just 1 col1 and 1 col2 but keeping the right strings being printed which is working?</p>

<pre><code>&lt;div class="feature-text"&gt;
&lt;?php 
//Now print the associated cms_page_parts
$qpp = $conn-&gt;query("SELECT * FROM cms_page_part WHERE page_id=$id"); 
$rpp = $qpp-&gt;fetchAll(PDO::FETCH_ASSOC);

foreach ($rpp as $row) {
?&gt;
  &lt;div id="col1"&gt;
    &lt;p&gt;&lt;?php echo $row['name']=='body' ? $row['content_html'] : NULL; ?&gt;&lt;/p&gt;
  &lt;/div&gt;
  &lt;div id="col2"&gt;
    &lt;p class="testimonial"&gt;&lt;?php echo $row['name']=='sidebar' ? $row['content_html'] : NULL; ?&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;?php 
}
?&gt;
&lt;/div&gt;
</code></pre>
