title: Echo mixed code
body: <p>I'm trying to echo a mixed string containing html code and PHP code but every possible thing I tried didn't work out.</p>
  
  <p>Basically I want to do is looping the following code for 3 times. Giving me 3 divs with number incrementation in the name every time.</p>
  
  <p>This code is going to be used in a wordpress template.</p>
  
  <p>My normal code without echoing is the following:</p>
  
  <pre><code>&lt;div id="gallery &lt;?php $c; ?&gt;"&gt;
    &lt;?php query_posts('post_type=portfolio'); ?&gt;
    &lt;?php if(have_posts()) : ?&gt;
      &lt;?php while(have_posts()) : the_post(); ?&gt;
        &lt;?php if ( has_post_thumbnail() ) : ?&gt;
          &lt;a href="&lt;?php the_permalink(); ?&gt;" 
             title="&lt;?php the_title_attribute(); ?&gt;" &gt;
             &lt;?php the_post_thumbnail(); ?&gt;
          &lt;/a&gt;
        &lt;?php endif; ?&gt;
        &lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
        &lt;a href="&lt;?php the_permalink(); ?&gt;" 
           title="&lt;?php the_title_attribute(); ?&gt;" &gt; 
           &lt;h2&gt;View Project&lt;/h2&gt;
        &lt;/a&gt;
        &lt;?php the_content() ?&gt;
      &lt;?php endwhile; ?&gt;
    &lt;?php endif; ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I'm fairly new to PHP so I don't know how to echo this the proper way. 
  My for-loop has already been setup.</p>
  
  <p>I hope you guys can help me out.</p>
  
  <p>Kind regards
  Dragon54</p>