How to get days of leave taken in a given month
<p>I have a question regarding getting leaves of an employee in my php site.
We have two tables - 
<code>WORKDETAILS</code> consist of <code>emp_id</code>, <code>attendance_date</code> 
and 
<code>HOLIDAYS</code> consist of list of <code>holydays</code>. </p>

<p>Requirement is that list of  leaves of an employee in a given month should be displayed except weekends and days worked and normal holidays. its really challenging for me ,<strong>i need Help !</strong></p>

<pre><code>function dates_between($start_date, $end_date = false) 
{ 
 if ( !$end_date ) 
 { 
     $end_date = date("Y-m-d"); 
 } 

 $start_date = is_int($start_date) ? $start_date : strtotime($start_date); 
 $end_date = is_int($end_date) ? $end_date : strtotime($end_date); 

 $test_date = $start_date; 
 $day_incrementer = 1; 

 //db access
      $work_res = mysql_query("SELECT DISTINCT date FROM `work_details` WHERE  employee_id=28         and date between '2012-02-01' and '2012-02-29'");

 do  
 { 

 if(!(date('N', strtotime(date("Y-m-d", $test_date))) &gt;= 6))
 {
  while($row=mysql_fetch_array($work_res))
 {
  if((!(date('N', strtotime(date("Y-m-d", $test_date))) &gt;= 6))&amp;&amp;(date("Y-m-d",$test_date)==$row['date']))
                {
                   $test_date = $start_date + ($day_incrementer * 60 * 60 * 24);
                    $day_incrementer++ ;
                }
              else if(!(date('N', strtotime(date("Y-m-d", $test_date))) &gt;= 6))
                {
                    echo  date("Y-m-d", $test_date)."---"."\n";
                     $test_date = $start_date + ($day_incrementer * 60 * 60 * 24);
                     $day_incrementer++ ;
                 }

             }


  echo  date("Y-m-d", $test_date)"\n";
}
   $test_date = $start_date + ($day_incrementer * 60 * 60 * 24); 


 } while ( $test_date &lt;= $end_date &amp;&amp; $day_incrementer++ ); 
} 

dates_between("2012-02-01","2012-02-29"); //function call
</code></pre>
