title: Function to get mysql results in PHP 7
body: <p>I'm struggling with the following problem. Some years ago, I've written a function to retrieve MYSQL results (multiple rows). Till PHP7, this code worked fine:</p>
  
  <pre><code>function MultipleRows($query)
  {
      global $dbhost, $dbname, $dbuser, $dbpass;
      mysql_connect($dbhost, $dbuser, $dbpass)
          or die("Error! Couldn't &lt;b&gt;Connect&lt;/b&gt;.");
  
      mysql_select_db($dbname)
          or die("Error! Couldn't &lt;b&gt;Select database&lt;/b&gt;.");
  
      $result = mysql_query($query)
          or die("Error! Couldn't execute query.");
  
      if(($result)&amp;&amp;(mysql_num_rows($result)&gt;0))
      {
          return $result;
      } else {
          return false;
      }
      mysql_close();
  }
  </code></pre>
  
  <p>Now in PHP7, this code doesn't seem to work anymore. After a lot of searching I came up with this as a replacement but unfortunately it doesn't work:</p>
  
  <pre><code>function MultipleRows($query)
  {
      $mysqli = new mysqli($dbhost, $dbpass, $dbuser, $dbname); 
  
      $result = mysqli_fetch_all($mysqli-&gt;query($query), MYSQLI_ASSOC);
      return $result;
      $mysqli-&gt;close();
  }
  </code></pre>
  
  <p>The function is meant to work with code like this:</p>
  
  <pre><code>$res_test = MultipleRows("SELECT id, name FROM table");
  
  if($res_test)
  {
      while($res = mysql_fetch_array($res_test))
      {
          echo $res['id'].' '.$res['name'];
      }
  }
  </code></pre>
  
  <p>It's not a good option to rewrite the 'display code' (last fragment) because in that case I have to rewrite many lines in my website. Who can give me some help in this? Thanks in advance!</p>