title: Looping HTML code inside php while loop
body: <p>I want HTML code to repeat after every execution of <code>while()</code>. But it is not repeating. </p>
  
  <p>Actually, I want that on every line it reads a box is made with comment and like button at the bottom. Therefore I kept HTML code inside <code>while</code> loop but after running the code after every execution line are written in same box.</p>
  
  <p>Here is the code reference: </p>
  
  <pre><code>   &lt;?php
          $name = $_POST['name']; 
          $query = $_POST["query"];
          $po = "$name-$query";
          $myfile = fopen("posts.txt", "a+");
          fwrite($myfile,$po);
          fclose($myfile);
          $mypost=fopen("posts.txt","r");
          while(!feof($mypost)): ?&gt; &lt;!-- with this while loop i want this div class to repeat --&gt; 
      &lt;div class="w3-container w3-card w3-white w3-round w3-margin"&gt;&lt;br&gt;
      &lt;img src="/w3images/avatar2.png" alt="Avatar" class="w3-left w3-circle w3-margin-right" style="width:60px"&gt;
      &lt;span class="w3-right w3-opacity"&gt;1 min&lt;/span&gt;
              &lt;h4&gt;fdg&lt;/h4&gt;&lt;br&gt;
              &lt;hr class="w3-clear"&gt;
              &lt;p&gt; &lt;?php
              echo fgets($mypost);
              ?&gt;&lt;/p&gt;
              &lt;button type="button" class="w3-button w3-theme-d1 w3-margin-bottom"&gt;&lt;i class="fa fa-thumbs-up"&gt;&lt;/i&gt;  Like&lt;/button&gt; 
              &lt;button type="button" class="w3-button w3-theme-d2 w3-margin-bottom"&gt;&lt;i class="fa fa-comment"&gt;&lt;/i&gt;  Comment&lt;/button&gt; 
            &lt;/div&gt;
      &lt;?php endwhile; ?&gt;
  </code></pre>
  
  <p>Please help What can I do?</p>