1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
(isset($_POST['start_datetime']) && isset($_POST['end_datetime'])) { // si on a reçu une valeur du formulaire
// // $debut = date('Y-m-d H:i:s', strtotime($_POST["start_datetime"]));
// $debut = date('Y-m-d H:i:s', strtotime(str_replace('T', '', $_POST['start_datetime'])));
// // $depart = date('Y-m-d H:i:s', strtotime($_POST["end_datetime"]));
// $depart = date('Y-m-d H:i:s', strtotime(str_replace('T', '', $_POST['end_datetime'])));
// Retrieve the debut
$debut = $_POST['start_datetime'];
$depart = $_POST['end_datetime'];
// Convert it to a DateTime object
$datetimedebut = date_create($debut);
$datetimefin = date_create($depart);
// Get the Unix timestamp
$timestampd = $datetimedebut->getTimestamp();
$timestampf = $datetimefin->getTimestamp();
// Use the timestamp in the database query
$heure = $conn->query("SELECT DISTINCT * FROM salles LEFT JOIN locations ON salles.Idsalle = locations.Idsalle where( (DateDebut is not null and (DateDebut > $timestampd and DateFin < $timestampf )) or DateDebut is null and DateFin is null) ");
//loop
while ($ligne = $heure->fetch(PDO::FETCH_ASSOC)) {
echo "nom:" . $ligne['nom'] . '<br>';
echo "nom:" . $ligne['lieu'] . '<br>';
echo '<button>réserver</button><br><br>';
}
} |