Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

PHP calendar making booked days red

220061

Well-Known Coder
hello! i'm making a calendar that shows which days have been booked and which are available.
In my db I have two important cols for this called: start_date and end_date (translation is start_datum and eind_datum)
Now I'm trying to make the days that are booked have the red booked label. the problem starts when I do this:
(written in d-m-y)
reservation is from 14-06-2022 till 18-06-2022
14-06-2022 = start_datum
18-06-2022 = eind_datum
those two dates turn red like they should be but all the dates in between don't change at all. I have tried to use a for loop to get this fixed but it's showing no difference. I'm out of idea's and was wondering if someone else knew what to do
PHP:
        if(in_array($date, $bookings)){

            // misschien lukt het nog met de tutorials erbij sze hebben er namelijk nog mee rgemaakt
           print_r($bookings);
        //     echo "<br>";
        //     echo $date;
        //     echo "<br>";
        $timestampStart_datum = strtotime($start_datum);
        //schets voor mktime()
        //mktime(Hour, minute , second, month, day, year);
        $testing = mktime(0, 0, 0, $timestampStart_datum);
        echo $testing, "<---- dit is de variable testing";
        echo "<br>";
        $timestampEind_datum = strtotime($eind_datum);
        $testingEind = mktime(0, 0, 0, $timestampStart_datum);
        echo $testingEind, "<---- dit is de variable testing eind";
        echo "<br>";
        $seconds = 24 * 60 * 60;
        echo "<br>";
        // echo $start_datum;
        // echo "<br>";
        // echo $eind_datum;
        // echo "<br>";
        if($start_datum < $date){
            echo "testing";
        }else{
            echo "testing gone wrong????";
        }
        echo "<br>";
        echo $currentDay . "<--- dit is de current day";
        echo "<br>";
        echo $testing . "<--- dit is de testing day";
        echo "<br>";
        echo $testingEind . "<--- dit is de testingEind day";
        echo "<br>";
        echo $today . "<--- dit is de today day";
        echo "<br>";
        echo $date . "<--- dit is de date day";
        echo "<br>";
            for ($date = $testing; $date <= $testingEind; $date++) {
                //$next = date("F j, Y", $date);
             $calendar.="<td class='$today'><h4>$currentDay</h4><a class='btn btn-danger btn-xs'>booked</a></td>";
            }
           // $calendar.="<td class='$today'><h4>$currentDay</h4><a class='btn btn-danger btn-xs'>booked</a></td>";
        }else{
            $calendar.="<td class='$today'><h4>$currentDay</h4><a class='btn btn-success btn-xs'>Beschrikbaar</a></td>";
        }
        $currentDay++;
        $dayOfWeek++;

    }
 

Buy us a coffee!

Back
Top Bottom