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
| function verif($name, $choicecity, $datedebut, $datefin){
$servername = 'localhost';
$username = 'root';
$password = '';
$dbase = 'mabase';
$today = date("Y-m-d");
$chambre=100;
while(++$chambre <=105){
$mysqli = new mysqli ('127.0.0.1', 'root','', 'mabase');
$result = $mysqli->query("SELECT nom, debut, fin, chambre FROM reservation WHERE choicecity ='$choicecity' and chambre='$chambre'");
$row= $result->fetch_array();
/*echo 'test pour la chambre' . $chambre .'<br>';*/
if ((!isset ($row ['debut'])) and (!isset ($row ['fin']))) {/* aucune reservation pour cette ville */
$pdo = new PDO("mysql:host=$servername;dbname=$dbase","$username","$password");
$city = "UPDATE reservation SET debut='$datedebut', fin='$datefin',
choicecity='$choicecity', chambre='$chambre' WHERE nom='$name'";
$resultcity = $pdo->exec($city);
}
elseif (($datedebut >= ($row ['fin'])) || ($datefin < ($row ['debut'])) ) {
/* la solution est la mais ou ????*';
}
}
if (($datedebut >= ($row ['debut'])) && ($datedebut <= ($row ['fin']))){
echo 'date de depart pour la ville de '. $choicecity .'déja prise';
}
} |
Partager