Skip to content
Advertisement

PHP calendar to block some not available dates

I’m designing a little PHP calendar for a little booking system. The final feature is to block some not available dates, that I have stored in a PHP array. What is the best way to achieve this? Please I need some recommendations about how to do this. Thanks

JavaScript

if I have an array in php with dates in this format “2020-08-12” that must be not available or not selectable how can I do.

here html code

JavaScript

Advertisement

Answer

For every <td> that you output, check if its date is in your list of unavailable dates and output a class name so you can target it with CSS.

Change this code:

JavaScript

To this:

JavaScript

This assumes the array of unavailable dates is stored in $unavailable_dates, e.g. ['2020-08-10', '2020-08-12', '2020-08-17'].

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement