I'm trying to build a reservation system for a hotel and I don't know how to select just the available rooms?
I have two tables:
table of rooms with called "chambre" it have: id, libelle
and table called" reservation_client" it has: id, id_client, id_chambre, start, end
.
For the start and end they are the start date of reservation and the end of reservation
This is my select form:
<div class="form-group">
<label class="col-sm-2 control-label">Chambre</label>
<div class="col-sm-9">
<select class="form-control" name="id_chambre">
<option>Selectionnez une chambre</option>
<?php
/*echo $req2=$bdd->query('SELECT * FROM reservation_client WHERE $donnees["start"]!==$_POST["start"] ' )/*or die (print_r($bdd->errorinfo()))*/
$req=$bdd->query('SELECT * FROM chambre' )/*or die (print_r($bdd->errorinfo()))*/;
$req2=$bdd->query('SELECT * FROM reservation_client ' );
while ($donnees = $req->fetch() ) {
echo"<option value='".$donnees['id']."'>".($donnees['libelle']) ."</option> " ;
}
?>
</select>
</div>
</div>
I tried this code but without any result:
$req2=$bdd->query('SELECT * FROM reservation_client WHERE start<end AND end>star ' );
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…