我正在尝试比较租金开始和租金结束的两个日期,但数据库中的某些车辆可能已经在这些日期租用
我已经有一个代码阻止用户在两个日期之间预订汽车,但在那之后它仍然被阻止
if( empty($content) ){
extract($_POST); // here i extract my _post
if( !empty($idmembre) ){
$vehicule = execReq( "SELECT * FROM vehicule WHERE idvehicule=:idvehicule", array(
'idvehicule' => $idvehicule
));
$infoVehicule = $vehicule->fetch();
$agence = $infoVehicule['agences_idagences'];
$timestamp1 = strtotime($date_heure_depart);
$timestamp2 = strtotime($date_heure_fin); // here i create two timestamps to compare with what i have en my database
$date_deja_prise = execReq( "SELECT * FROM commande WHERE vehicule_idvehicule=:idvehicule", array(
'idvehicule' => $idvehicule
));
while( $date = $date_deja_prise->fetch() ){
if( !empty($date) ){ // here if one vehicle has a date of rent it checks evry one to check if the date is taken
$date_debut = strtotime($date['date_heure_depart']);
$date_fin = strtotime($date['date_heure_fin']);
if( ($date_debut <= $timestamp1 || $timestamp2 <= $date_fin) ){
$content .= '<div class="alert alert-danger">Le véhicule '.$infoVehicule['titre'].' est déjà louer du '.$date['date_heure_depart'].' au '.$date['date_heure_fin'].' inclu</div>';
}
}
}
所以基本上它可以在我的 phpmyadmin 页面中创建一行,在那里预订汽车一段时间,之后如果我尝试预订另一辆车,但所有日期都不同,我不能
森栏