title: Get all rows from MySQL Query
body: <p>The PHP Code:    </p>
  
  <pre><code>&lt;?php
  //Server Information
  $servername = "localhost";
  $dbusername = "USERNAME";
  $password = "TOTALLYSECUREPASSWORD";
  $dbname = "DEFINITELYADATABASE";
  
  //Query Information
  $guid = $_POST['GUID'];
  $username = $_POST['USERNAME'];
  $admin_username = $_POST['ADMIN_USERNAME'];
  $ban_reason  = $_POST['BAN_REASON'];
  $ip = $_POST['IP'];
  
  //Create Connection
  $connection = mysqli_connect($servername, $dbusername, $password, $dbname);
  
  //Check the Connection
  if ($connection-&gt;connect_error){
      die("Connection failed: " . $connection-&gt;connect_error);
  }
  
  //$sql = "SELECT DATE, DBUSERNAME, GUID, IP, USERNAME, BAN_REASON FROM bans";
  //$result = $connection-&gt;query($sql);
  
  $sql = "SELECT * FROM bans WHERE";
  
  $types = json_decode($_POST['QUERY_TYPE'], true);
  
  if (in_array("query_admin_username", $types)) {
      $sql = $sql . " DBUSERNAME = " . "\"" . $admin_username . "\"" . " &amp;&amp;";
  }
  
  if (in_array("query_guid", $types)) {
      $sql = $sql . " GUID = " . "\"". $guid . "\"" . " &amp;&amp;";
  }
  
  if (in_array("query_ip", $types)) {
      $sql = $sql . " IP = " . "\"" . $ip . "\"" . " &amp;&amp;";
  }
  
  if (in_array("query_username", $types)) {
      $sql = $sql . " USERNAME = " . "\"" . $username . "\"" . " &amp;&amp;";
  }
  
  if (in_array("query_ban_reason", $types)) {
      $sql = $sql . " BAN_REASON = " . "\"" . $ban_reason . "\"" . " &amp;&amp;";
  }
  
  $sql_query = substr($sql, 0, -3);
  
  echo ($sql_query);
  
  $result = $connection-&gt;query($sql_query);
  
  while ($connection-&gt;query($sql_query)) {
  
  }
  
  if (!$result) {
      die("Invalid Query: " . mysqli_error());
  }
  
  $row = $result-&gt;fetch_array(MYSQLI_NUM);
  
  while ($row = mysqli_fetch_assoc($result)) {
      echo ($row);
  }
  
  mysqli_close($connection);
  ?&gt;
  </code></pre>
  
  <p>As weird as all that looks, it works just how I want it to (I think).</p>
  
  <p>My issue:</p>
  
  <p>I want to be able to get the data from each row and export it as one large String, something along the lines of:</p>
  
  <pre><code>[DATE] DBUSERNAME banned USERNAME (GUID / IP) for BAN_REASON.
  </code></pre>
  
  <p>I just have absolutely no idea how to go about this. I've tested the Query and it's returning everything it should, however I was using "echo ($row[0])" etc to display them, which is pretty impractical if it's going to return a large amount of rows.</p>
  
  <p>Sorry if something doesn't make sense, my brain is fried at the moment. Please let me know if I forgot anything.</p>