title: How to check if name already in the table? Querying Mysql for sum of each day and then populating an HTML data through PHP with it
body: <p>So, this is my first question here, and I'd really appreciate if someone could help me. I currently have a Mysql database and a web app made with PHP where the users can input how much time they have used on a specific task that day. </p>
  
  <p>Right now I would like to populate an HTML table with the SUM of each days activity in hours. My problem is that I can't find a way to check if the name field is unique, as the data contains many rows with the same name field, one for each day. </p>
  
  <p>I have this Mysql query:</p>
  
  <pre><code>SELECT 
      t_email.name, 
      DATE_FORMAT(input_date,'%d') AS days, 
      SUM(time_worked) AS totalTime
  FROM 
      t_transactions 
      LEFT JOIN t_email ON t_transactions.email_id &gt;= t_email.email_id 
  WHERE 
      DATE_FORMAT(input_date,'%m') = '02'
      AND DATE_FORMAT(input_date,'%Y') = '2019' 
  GROUP BY DATE_FORMAT(input_date,'%d') 
  ORDER BY t_email.name
  </code></pre>
  
  <p>Which returns me a table like this: </p>
  
  <pre><code>name  days  totalTime
  james 01    5.00 
  james 06    2.00 
  jimmy 02    4.0
  </code></pre>
  
  <p>And so on. I'm using the below PHP: </p>
  
  <pre><code>&lt;?php 
  foreach ($monthly_data_per_day as $row): ?&gt;
  &lt;tr&gt;
      &lt;td&gt;&lt;?= $row['name'] ?&gt;&lt;/td&gt;
      &lt;?php
      $num_days = date('t');
      for ($i = 1; $i &lt;= $num_days; $i++) {
          if ($row['days'] == $i) {
              echo "&lt;td&gt;" . $row['totalTime'] . "&lt;/td&gt;";
          } else {
              echo "&lt;td&gt;" . 0 . "&lt;/td&gt;";
          }
      }?&gt;&lt;/tr&gt;
  &lt;?php endforeach;?&gt;
  </code></pre>
  
  <p>I'd like to have an HTML table where after each name in the database, you could see how many hours that person has done that day. So columns from 1 to how many days there are in the month. </p>
  
  <p>Right now I get a row for each day, with the correct sum of time worked on just one column, as there's one row per column. </p>
  
  <p>Here's a picture of what I'd like the table to look like: </p>
  
  <p><a href="https://i.stack.imgur.com/1uOgt.png" rel="nofollow noreferrer">A picture of the table with columns for each day of the month</a></p>