I have a Log in PHP which shows all the things I've done.
the construction is like:
Date -- Things done -- Hours
I figured how to show all the info in a table. But I want to have a total hours in the bottom which calculated all the hours of the database.
I'm adding every day a new log (what I've done that day). But I wanna know how I can do this. I've been searching for a while now, without success..
I hope anyone can help me.
Thanks in advance.
This is how I display my code(short version):
<tr>
<td class="date"><?php echo $row['Date'] ?></td>
<td><?php echo $row['Detail'] ?></td>
<td><?php echo $row['Hours'] ?></td>
</tr>
So for clarification:
I make a new td which echo's the total hours by adding all the hours.
So if my hours are 8 + 8 + 8 + 8 + 4 + 5 in the hours table it will be shown as:
Total hours: 41 hours
To display the total sum of hours, you do this:
If
date
is of typ datetime/date/timestamp you can get the total for every day like this (If thedate
is of type date, you do not needDATE(
date)
):If
date
is of typ int or PHP timestamp you can get the total for every day like this: