I have two tables one is tblemployee having employee name, employee id and another table tblleaves having empid,Leave_Date, fromDate, toDate, Description.
If employe
Updated your code based on your requirement, didn't tested it. Let's give it a try.
prepare($sql);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($query->rowCount() > 0)
{
foreach($results as $result)
{
$leavedates = explode(',', $result->Leave_Dates);
$period = new DatePeriod(
new DateTime($leavedates[0]),
new DateInterval('P1D'),
new DateTime($leavedates[1])
);
$listofleaves = [];
foreach ($period as $key => $value) {
$listofleaves[] = $value->format('Y-m-d');
}
$listofleaves[] = $leavedates[2];
?>
FirstName);?> LastName);?>
Leave_Days);
?>