Click here to Skip to main content
15,887,376 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello I'm trying to create a calendar with booked dates for a while now but with no succes I was wondering if someone else could see what is going wrong. I have alreasy tried 2 ways.
first one is a very big calendar on the website that shows booked dates. Though it does do the job its just not exactly what I want to have.

it's more like my second version.
an input type of text what when you click on it will show a calendar with dates that you can pick.
this is the source code:
<?php include "config.php"; ?>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Display multiple months</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<?php
//https://www.syncfusion.com/forums/152695/i-want-to-disable-the-datepicker-holiday-dates-which-are-stored-in-database
//https://www.google.com/search?q=javascript+make+connection+to+db&rlz=1C1CHZN_nlNL992NL992&oq=javascript+make+connection+to+db&aqs=chrome..69i57j33i160l3j33i22i29i30l2.7107j0j15&sourceid=chrome&ie=UTF-8
 $huis_ID = "1";

 $sql = "SELECT * FROM reserveringen WHERE huis_ID = ?";
 $stmt = $conn->prepare($sql);
 $stmt->bind_param("i", $huis_ID);
 $stmt->execute();
 $result = $stmt->get_result();
 $data = $result->fetch_all(MYSQLI_ASSOC);
 if ($data):
   ?> 
        <?php foreach($data as $row): ?>
            <?php 
            $start_datum = date('d-m-Y', strtotime($row['start_datum']));
            echo $start_datum , "<br>"; 
            $eind_datum = date('d-m-Y', strtotime($row['eind_datum']));
            echo $eind_datum , "<br>"; 
            ?>
        <?php endforeach ?>
    <?php else: ?>
        No data found
    <?php endif ?>

<script>
    

$(function() {
    $( "#datepicker" ).datepicker({
    numberOfMonths: 1,
    minDate:0,
    showButtonPanel: true,
    
   
    });
});
$(function() {
    $( "#datepicker1" ).datepicker({
    numberOfMonths: 1,
    minDate:1,
    showButtonPanel: true,
    
   
    });
});
</script>
</head>
<body>
<p>start_date: <input type="text" id="datepicker" name ="datepicker"></p>

<p>end_date: <input type="text" id="datepicker1" name ="datepicker1"></p>

</body>
</html>

what it does is it shows the calendar and you are not allowed to go back in months. this is what I want to have but now I want to have blocked (in red) dates. based on the booked dates that are in the db

in the foreach loop you will see the dates shown now I want to use these dates to create the blocked (in red) dates how do I fix this?

What I have tried:

So first I tried to make a big calendar but this just showed booked dates I don't want that. I want kinda what I have now but with the booked dates
Posted
Updated 3-Jul-22 4:11am
v2
Comments
Member 15627495 3-Jul-22 3:18am    
explode the functionnality in several unity.

code the first, the simplest posible.
then code ( add ) the second functionnality.
and so , and so ...
where do you have an error ?
minoesje minoes 3-Jul-22 10:12am    
I don't have errors? I just don't know how to add my mysqli dates in my calendar en block them
minoesje minoes 3-Jul-22 4:03am    
?? I'm not understanding? These are the two last things that need to be done?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900