title: Editable appointment system
body: <p>I've been to this site several times before for help which I've managed to solve problems encountered in the past but this time I think I'm going to actually have to ask my own question.</p>
  
  <p>I am working on a system in which employees of a small company can put in their appointments they had every week of the month, including the appointments, number of sales and amount of money made from them. I already calculated things like the success percentage and everything.</p>
  
  <p>Now here lies the problem:
  I need to make it so that the week numbers are automatically calculated rather than just put in 5 weeks a month.(Currently it works like: January 1-5  February 5 - 10 and so forth) And the numbers need to be linked to a page where the user can edit the information of that week.</p>
  
  <p>I already know how to make a page like this too, the only thing I really need help with is finding out how to best put the week numbers in properly. (Security not being really an issue because it runs on an internal web server.)</p>
  
  <p>Here's the table segment of my calendar.php :</p>
  
  <pre><code>&lt;table id='myTable' width="600" border="1" cellspacing="3"&gt;
          &lt;tr&gt;
      &lt;th align="left"&gt;
          &lt;a href="&lt;?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&amp;year=" . $prev_year; ?&gt;"&gt; Prev &lt;/a&gt;&lt;/th&gt;
      &lt;th colspan='3' width="200"&gt;&lt;?php echo $monthNames[$cMonth-1].' '.$cYear; ?&gt;&lt;/th&gt;
      &lt;th align="right"&gt;&lt;a href="&lt;?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&amp;year=" . $next_year; ?&gt;"&gt; Next &lt;/a&gt;&lt;/th&gt;&lt;/tr&gt;
      &lt;?php
          echo "&lt;tr align='center'&gt;";
      //Rather than a loop, need to get the amount of weeks in each month.
      $startingMonthWeekNum = ((($cMonth-1)*5)+1);
      $endingMonthWeekNum = ($cMonth*5+1);
  
                          echo "&lt;tr&gt;&lt;th&gt;Week #&lt;/th&gt;&lt;th&gt;Afspraken&lt;/th&gt;&lt;th&gt;Sales&lt;/th&gt;&lt;th&gt;Omzet&lt;/th&gt;&lt;th&gt;Conversie %&lt;/th&gt;&lt;/tr&gt;";                          
  
  for($i = $startingMonthWeekNum; $i &lt; $endingMonthWeekNum; $i++)
  {
   //Reset variables
      $appointments = null;
      $sales = null;
      $revenue = null;
      $conversie = null;
  
      $result = mysqli_query($con, "SELECT * FROM cms_appointments where date_week = $i and date_year = $cYear and id_user = $userId group by date_week");
      $sumAppointments = 0;
      $sumSales = 0;
      $sumRevenue = 0;
      while($row = mysqli_fetch_array($result))
      {
  $weekRow = $row['date_week'];                           
  $appointments = $row['appointments'];
  $sales = $row['sales'];
  $revenue = $row['revenue'];
  $conversie = $appointments &gt; 0 ? ($sales / $appointments)*100 : 0;
  
  }
  $sumAppointments += $appointments;
  $sumSales += $sales;
  $sumRevenue += $revenue;
  echo "&lt;tr align='center'&gt;";
  echo "&lt;td&gt;$i&lt;/td&gt;&lt;td&gt;$appointments&lt;/td&gt;&lt;td&gt;$sales&lt;/td&gt;&lt;td&gt;$revenue&lt;/td&gt;&lt;td&gt;$conversie&lt;/td&gt;";
  echo "&lt;/tr&gt;";
  }
  echo "&lt;tr align='center'&gt;&lt;td&gt;Total&lt;/td&gt;&lt;td&gt;$sumAppointments&lt;/td&gt;&lt;td&gt;$sumSales&lt;/td&gt;&lt;td&gt;$sumRevenue&lt;/td&gt;&lt;td&gt;".($sumAppointments &gt; 0 ? ($sumSales / $sumAppointments)*100 : 0)."&lt;/td&gt;&lt;/tr&gt;";
  echo "&lt;/tr&gt; &lt;/table&gt;";
      mysqli_close($con);
      ?&gt; 
  </code></pre>
  
  <p>I have a small database behind this with the table cms_appointments having all the information in them which are used in this code. The appointments, sales and revenue.</p>
  
  <p><em>This is the first time I posted a question and if it can be improved in some way, I will try my best to make it easier as this site helped me out greatly in the past, I want to leave this as a well explained first question.</em></p>