<?php include_once("connection.php"); 
// Define the start date of the week (assuming the current week)
$startDate = date('Y-m-d', strtotime('monday this week'));

// Define the end date of the week
$endDate = date('Y-m-d', strtotime('sunday this week'));

// Generate an array of days in the week
$daysInWeek = [];
$currentDate = $startDate;
while ($currentDate <= $endDate) {
    $daysInWeek[] = $currentDate;
    $currentDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate)));
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Weekly Calendar</title>
    <style>
        .calendar {
            width: 100%;
            border-collapse: collapse;
        }
        .calendar th, .calendar td {
            border: 1px solid #ccc;
            padding: 5px;
            text-align: center;
        }
        .calendar th {
            background-color: #f2f2f2;
        }
    </style>
</head>
<body>
    <h2>Weekly Calendar</h2>
    <table class="calendar table table-striped table-bordered dt-responsive nowrap">
        <thead>
            <tr> <th>Timming</th>
                <?php foreach ($daysInWeek as $day): ?>
                    <th><?php echo date('l, d M Y', strtotime($day)); ?></th>
                <?php endforeach; ?>
            </tr>
        </thead>
        <tbody><?php $queryls1q = "select * from time_slot";
$resultls1q  = mysqli_query($conn,$queryls1q);	
while($row=mysqli_fetch_array($resultls1q))
{ $time_slot = $row['time_slot'];
?>
            <tr><td><?php echo $time_slot?></td>
                <?php foreach ($daysInWeek as $day): ?>
                    <td>
                        <?php
						
						
						$queryls1 = "select * from therapy_chart_more where appointment_date='$day' and appointment_time='$time_slot'";
$resultls1  = mysqli_query($conn,$queryls1);	
while($row=mysqli_fetch_array($resultls1))
{
$patient_name = $row['patient_name'];
$therapy_name = $row['therapy_name'];
$therapist_name =  $row['therapist_name'];
$appointment_time = $row['appointment_time'];

                        // Replace this with your logic to fetch and display data for each day
                       ?><?php echo $therapist_name?><br /><?php echo $patient_name?><br /><?php echo $therapy_name; }?>
                    </td>
                <?php endforeach; ?>
            </tr><?php } ?>
        </tbody>
    </table>
</body>
</html>
