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 36 37 38 39 40 41 42 43 44 45 46 47 48
| <?php
try
{
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO('mysql:host=localhost;dbname=camping', 'root', '', $pdo_options);
$reqeplt = $bdd->prepare('select count(Id_emplacement), Id_emplacement from emplacement where ombrage in ( ? ) and piscine_proche in ( ? ) and proche_sanitaire in ( ? )
and Id_emplacement not in (select Id_emplacement from reservation where
(
(? >= arrivee AND ? < depart )
OR
(? > arrivee AND ? <= depart)
OR
(? < arrivee) AND (arrivee < ? )
OR
(? = arrivee) AND (depart = ? )
OR (? = arrivee) ))');
$rest = substr($_POST["listMois"], -6, 2);
$arrivee=mktime($rest, $_POST["listJour"], 2011); // arrivée au camping
$depart=mktime($rest, $_POST["listJour"]+$_POST['duree'], 2011); // départ du camping
$reqeplt->execute(array( $_POST['ombrage'], $_POST['piscine'], $_POST['sanitaire'], '$arrivee', '$arrivee', '$depart', '$depart','$arrivee',
'$depart','$arrivee','$depart','$arrivee'));
foreach ($reqeplt as $row){
$nbligne= $row['count(Id_emplacement)'] ;
}
echo $nbligne."<br/>";
$reqeplt->execute(array( $_POST['ombrage'], $_POST['piscine'], $_POST['sanitaire'], '$arrivee', '$arrivee', '$depart', '$depart','$arrivee',
'$depart','$arrivee','$depart','$arrivee'));
while($donnees = $reqeplt->fetch()) {
echo " resultats : ".$donnees['Id_emplacement']."<br/>";
}
$reqeplt->closeCursor();
catch(Exception $e){
die('Erreur : '.$e->getMessage());
}
?> |