title: How to return the results from a Mysqli prepared statement
body: <p>Im studying Mysqli at the moment.
  But i have a problem about how to return a resultset from a mysqli prepared statement.
  I have the following code in Loginclass.php:</p>
  
  <pre><code>$stmt = mysqli_stmt_init($db-&gt;getCon());
  
      $stmt-&gt;prepare('SELECT * FROM `user` WHERE `user_username` = ? AND `user_password` = ?');
          $user_username = $this-&gt;_user_name;
          $user_password = $this-&gt;_password;
      $stmt-&gt;bind_param('ss', $user_username, $user_password);
      $stmt-&gt;execute();
  
      $stmt-&gt;store_result();
  
      if($stmt-&gt;num_rows() == 0) {
          return false;
      }
  
      else {
          $this-&gt;setPass(true);
          return $result;
      }
  </code></pre>
  
  <p>Now i want in login.php to do the following with the returning $result var:</p>
  
  <pre><code>while ($row = $result-&gt;fetch_assoc()) {
  
  $_SESSION['login']['user_id'] = $row['user_id'];
  
  }
  </code></pre>