I have search for this for how many days but i dndnt get a nice tutorial..
I made a table called 'table_count'
employeeID datefrom dateto name typeofleave day(s)
===================================================================
1 2011/1/1 2011/1/2 jayson annual leave 1
2 2011/1/2 2011/1/3 shawn sick leave 1
1 2010/12/25 2010/12/27 jayson vacation leave 2
1 2010/12/1 2010/12/3 jayson annual leave 2
1 2010/11/1 2010/11/4 jayson vacation leave 3
2 2010/10/1 2010/10/2 shawn annual leave 1
2 2010/9/6 2010/9/9 shawn vacation leave 3
1 2009/1/1 2009/2/2 jayson sick leave 3
1 2008/5/1 2008/5/3 jayson sick leave 3
scenario I want to display the example below.
employee Id (1) Annual leave = 3
Vacation leave = 5
sick leave = 6
Total Leave: 14
employee Id (2) Annual leave = 1
Vacation leave = 3
sick leave = 1
Total leave: 5
any link guys? help will be appreciated ;D
count total of leave by groups and by specific id.
Moderator: General Moderators
Re: count total of leave by groups and by specific id.
Is this what you mean?
Code: Select all
SELECT SUM(days) AS total_days FROM table_count WHERE employeeID = 1Re: count total of leave by groups and by specific id.
no, it isn't. as per example say. Id like to count the total leaves for specific id.
ex.
ID: 1
Vacation leave = 5
sick leave = 6
Total Leave: 14.
I dont like to see the records of other users. I just wanted them to see their records only. thanks
ex.
ID: 1
Vacation leave = 5
sick leave = 6
Total Leave: 14.
I dont like to see the records of other users. I just wanted them to see their records only. thanks
Re: count total of leave by groups and by specific id.
Code: Select all
$query = "SELECT typeofleave, leave FROM table_count WHERE employeeID = 1";
$result = mysql_query($query);
$total_leave = 0;
while ($row = mysql_fetch_assoc($result))
{
echo "{$row['typeofleave']}: {$row['leave']}<br />";
$total_leave += $row['leave'];
}
echo "Total leave: {$total_leave}";