title: PHP, SQL. Arrange worker / hostess working shift in 7 days / weekly view timetable. Where first column is current date
body: <p>Currently I'm doing hostess booking system. Whenever a customer book it'll be displayed at scheduled.php.</p>
  
  <p>My problem is that:
   1. The name of a host keep repeating, I just want I appear once in a row. 
   2. And instead of populating a row horizontally. It populate the table
      vertically.
   3.</p>
  
  <p>This is data in database. idtime is primary key in timesheet table. idemp is foreign key from employee table.
  <a href="https://i.stack.imgur.com/OaFcW.png" rel="nofollow noreferrer">View image</a></p>
  
  <p>This is my current code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  // Include config file
  require_once "config.php";
  
  // Part for &lt;th&gt; on table
  // today date
  $datenow = date('d-m-y');
  $daynow = date('l');
  // Next date and day from current date
  $date1 = date('d-m-y', strtotime("+1 day"));
  $day1 = date('l', strtotime("+1 day"));
  // Next 2 date and day from current date
  $date2 = date('d-m-y', strtotime("+2 day"));
  $day2 = date('l', strtotime("+2 day"));
  // Next 3 date and day from current date
  $date3 = date('d-m-y', strtotime("+3 day"));
  $day3 = date('l', strtotime("+3 day"));
  // Next 4 date and day from current date
  $date4 = date('d-m-y', strtotime("+4 day"));
  $day4 = date('l', strtotime("+4 day"));
  // Next 5 date and day from current date
  $date5 = date('d-m-y', strtotime("+5 day"));
  $day5 = date('l', strtotime("+5 day"));
  // Next 6 date and day from current date
  $date6 = date('d-m-y', strtotime("+6 day"));
  $day6 = date('l', strtotime("+6 day"));
      
  // SQL for to fetch data from database
  $time = mysqli_query($link, "SELECT * FROM timesheet WHERE date_time &lt;= CURDATE() + 6");
      
  $time1 = mysqli_query($link, "SELECT * FROM timesheet WHERE date_time = CURDATE() + 1");
  
  
  
  mysqli_close($link);
  ?&gt;
  
  &lt;div style="text-align: center;"&gt;
      &lt;a href="addshift.php" class="btn btn-success"&gt;Addshift&lt;/a&gt;
  &lt;/div&gt;    
  
  &lt;br&gt;&lt;br&gt;
  
  &lt;section&gt;
      &lt;div class="container"&gt;
          &lt;table class="table bordered"&gt;
              &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th&gt;Host&lt;/th&gt;
                      &lt;th&gt;&lt;?php echo $daynow . "&lt;br&gt;" . $datenow; ?&gt;&lt;/th&gt;
                      &lt;th&gt;&lt;?php echo $day1 . "&lt;br&gt;" . $date1; ?&gt;&lt;/th&gt;
                      &lt;th&gt;&lt;?php echo $day2 . "&lt;br&gt;" . $date2; ?&gt;&lt;/th&gt;
                      &lt;th&gt;&lt;?php echo $day3 . "&lt;br&gt;" . $date3; ?&gt;&lt;/th&gt;
                      &lt;th&gt;&lt;?php echo $day4 . "&lt;br&gt;" . $date4; ?&gt;&lt;/th&gt;
                      &lt;th&gt;&lt;?php echo $day5 . "&lt;br&gt;" . $date5; ?&gt;&lt;/th&gt;
                      &lt;th&gt;&lt;?php echo $day6 . "&lt;br&gt;" . $date6; ?&gt;&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
                  
                  &lt;?php while($empTime = mysqli_fetch_assoc($time)) { ?&gt;
                  &lt;tr&gt;
                      
                      &lt;td&gt;&lt;?php echo $empTime ['namekanji']; ?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;?php echo $empTime ['start_time']; echo " - "; echo $empTime ['end_time']; ?&gt;&lt;/td&gt;
                      
                      
                  &lt;/tr&gt;
                  &lt;?php } ?&gt;
                  
              &lt;/tbody&gt;
          &lt;/table&gt;
      &lt;/div&gt;
  &lt;/section&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is what my code display: <a href="https://i.stack.imgur.com/jsR2t.png" rel="nofollow noreferrer">View image</a></p>
  
  <p>This is what I wanted, not everyday the host is booked. Some day they didn't have to work:
  <a href="https://i.stack.imgur.com/fOWGe.png" rel="nofollow noreferrer">View image</a></p>
  
  <p>Thank you for helping.</p>