title: IF inside WHILE with database result not working
body: <p>I have a simple ticket sale registration system with 6 types of tickets and 3 different "physical" sales locations. Each order is inserted as a row in the database and stores the amount of each type of ticket along with the sale location, total cost and a datetime timestamp.</p>
  
  <p>I want to display the total amount of each ticket type, that was sold within a given time frame along with the total cost of those tickets. I also want to filter the results based on sale location.</p>
  
  <p>This is my db query:</p>
  
  <pre><code>"SELECT SUM(ticketType1), SUM(ticketType2), SUM(ticketType3), 
          SUM(ticketType4), SUM(ticketType5), SUM(ticketType6), 
          SUM(cost), saleLocation 
   FROM `orders` 
   WHERE time BETWEEN '2018-07-10 07:00:01' 
              AND '2018-07-11 07:00:00'"
  </code></pre>
  
  <p>Then I display it in a HTML table row:</p>
  
  <pre><code>&lt;?php 
  while ($row = $result-&gt;fetch_assoc()) {
      if($row["saleLocation"] == 'location1') { ?&gt;
          &lt;div class="cell"&gt;
              &lt;?php echo $row["SUM(ticketType1)"] ?&gt;
          &lt;/div&gt;
  
          &lt;div class="cell"&gt;
              &lt;?php echo $row["SUM(ticketType2)"] ?&gt;
          &lt;/div&gt;
  
          &lt;div class="cell"&gt;
              &lt;?php echo $row["SUM(ticketType3)"] ?&gt;
          &lt;/div&gt;
  
          &lt;div class="cell"&gt;
              &lt;?php echo $row["SUM(ticketType4)"] ?&gt;
          &lt;/div&gt;
  
          &lt;div class="cell"&gt;
              &lt;?php echo $row["SUM(ticketType5)"] ?&gt;
          &lt;/div&gt;   
  
          &lt;div class="cell"&gt;
              &lt;?php echo $row["SUM(ticketType6)"] ?&gt;
          &lt;/div&gt;
  
          &lt;div class="cell"&gt;
              &lt;?php echo number_format($row["SUM(cost)"], 0, "", "."); ?&gt;
          &lt;/div&gt;
  
      &lt;?php } //end if
  
   } // end while
  ?&gt;
  </code></pre>
  
  <p>It works, but I'm trying to use an IF statement inside the WHILE loop to filter the result based on location, but the IF statement doesn't appear to have any effect and instead it displays the results from all 3 locations.
  I know I can easily modify the query to achieve this, but I would rather not do that in this specific case.</p>
  
  <p>I'm guessing that the problem still lies within the query, though?</p>
  
  <p>Some help would be greatly appreciated.</p>