title: How to fetch news from a db and print them on a PHP page?
body: <p>I want to fetch the last two news from a DB, then print them on a PHP page using a function.</p>
  
  <p>The two news should be printed one next to the other.</p>
  
  <p>This is what I've done so far, what am I doing wrong?</p>
  
  <p>This is the problem:</p>
  
  <p><img src="https://i.imgur.com/eSwggE5.jpg" alt=""></p>
  
  <pre><code>&lt;?php
      function getAllNewsHome(){
          $connection = mysqli_connect("localhost", "root", "", "serverName");
          $connection-&gt;query("SET NAMES 'utf8'");
          $rsNewsHome = mysqli_query($connection, "SELECT * FROM news ORDER BY id DESC LIMIT 2");
          $newsHome = mysqli_fetch_all($rsNewsHome, MYSQLI_ASSOC);
          mysqli_close($connection);
          for($i=0; $i &lt; count($newsHome); $i++){
              echo "
                  &lt;div class='container'&gt;
                      &lt;div class='row'&gt;
                          &lt;div class='col-xs-6'&gt;
                              &lt;h1&gt;".$newsHome[$i]['title']."
                              &lt;/h1&gt;
                              &lt;p&gt;".$newsHome[$i]['content']."
                          &lt;/div&gt;
                          &lt;div class='col-xs-6'&gt;
                              &lt;h1&gt;".$newsHome[$i]['title']."
                              &lt;/h1&gt;
                              &lt;p&gt;".$newsHome[$i]['content']."
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              ";
          }
      }
  ?&gt;
  </code></pre>