I am trying to make an appointment calendar and I am using html table for to do this. I want a situation where if a user clicks an empty cell (time slots e.g. 8:00 or 8:15 are divided into cells using ), a form pops up and the user fills the form. After the user fills the form, the form data is saved into a database. But if a cell slot has already been filled by a particular user, the data of that slot should be accessible to that user and greyed out to other users. If the cell is empty, it should make the cell clickable to everyone. But if the cell is not empty, that is, a user already booked an appointment in that cell, it should allow the cell to be clickable by only the user and admin and should not be clickable to other users. And also the user should be able to edit the content of the cell.
How do I go about this? I am using PHP and JavaScript.
Below is what I have done so far.
if($_SESSION['interval'] == 30)
{
echo "<td onclick=popUpForm('$hoursDisplay[$x]:00-$hoursDisplay[$x]:30','$date')> </td><td onclick=popUpForm('$hoursDisplay[$x]:30-".$hoursDisplay[$x+1].":00','$date')> </td>";
}
if($_SESSION['interval'] == 20)
{
echo "<td onclick=popUpForm('$hoursDisplay[$x]:00-$hoursDisplay[$x]:20','$date')> </td><td onclick=popUpForm('$hoursDisplay[$x]:20-$hoursDisplay[$x]:40','$date')> </td><td onclick=popUpForm('$hoursDisplay[$x]:40-".$hoursDisplay[$x+1].":00','$date')> </td>";
}
if($_SESSION['interval'] == 15)
{
echo "<td onclick=popUpForm('$hoursDisplay[$x]:00-$hoursDisplay[$x]:15','$date')> </td><td onclick=popUpForm('$hoursDisplay[$x]:15-$hoursDisplay[$x]:30','$date')> </td><td onclick=popUpForm('$hoursDisplay[$x]:30-$hoursDisplay[$x]:45','$date')> </td><td onclick=popUpForm('$hoursDisplay[$x]:45-".$hoursDisplay[$x+1].":00','$date')> </td>";
}