Create table and display marks

I have a table in html, which generates the days of the week of a month. I wanted to help you in a piece of code.

I want to show in front of each date of a particular employee point markings.

Example:

Monday - 07:30 12:00 13:30 17:00

It is very complicated to do this? I need help.

Remember that the point markings of the staff comes from my database table.

I show here how my bank:

table: markings
marking_id(int)
employee_id(int)
record(date)
date(date)

Example:

If an employee has worked only on “first day of June” and make the following markings: 07:30 12:00 13:30 17:00 show in the table, and the other days show the message: lack.

The end result of his point card would look something like this:

Code incomplete:

<table border="3">
  <tr>
  <th>Date</th>
  <th>Days of the week</th>
  <th>Markings</th>
  </tr><br />

    <?php


    $daysWeek[1] = 'Monday';
    $daysWeek[2] = 'Tuesday';
    $daysWeek[3] = 'Wednesday';
    $daysWeek[4] = 'Thursday';
    $daysWeek[5] = 'Friday';
    $daysWeek[6] = 'Saturday';
    $daysWeek[7] = 'Sunday';


    for($days = 1; $days <= date('t',strtotime('2016-06')); $days++)

    {
    echo "<tr>";
    echo "<th>".$days."</th>" . "<th>".$daysWeek[date('N', strtotime("2016-06-$days"))] ."</th>" . "<th>";


        }

   

?>    
</table>

i don’t see any relation to the database in your code.

If your intention is to display every day of a particular month, and either display the text string " 07:30 12:00 13:30 17:00" or the word “lack” if there is no database row for that date, I’d do something like this pseudo-code:

// query to select all rows for the selected employee where data is in the selected month
// so something like "select * from markings where employee_id = '1' and date between '01-06-2015' and '30-06-2015'"
// read all the results into an array. It only needs to contain the date
// loop through each day of the selected month
//   for each day:
//     if the date appears in your array, display the time string " 07:30 12:00 13:30 17:00"
//     else, display "lack".
// end of loop

If you’re getting the time markings from your table (though I can’t see how, given the table layout) then it might be slightly more complex.

Also you can lose the array of day names, and the tags for each row of the html table should be td rather than th:

    echo "<td>".$days."</td>" . "<td>".date('l', strtotime("2016-06-$days")) ."</td>" . "<td>";

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.