<option selected value="<?php echo $currentRoom['room_id']; ?> "><?php echo $currentRoom['room']; ?> </option> <?php } // if the needed check-out is bigger than the current check out but the needed check in is in the current range // -------- // ------- if ($neededMax > $currentMax) { if ($neededMin >= $currentMin && $neededMin < $currentMax) { $info = array('roomId' => $roomId, 'checkIn' => $currentCheckOut, 'checkOut' => $checkOut); if ($currentRoom = $model->searchSingleRoom($info)) { ?> <option selected value="<?php echo $currentRoom['room_id']; ?> "><?php echo $currentRoom['room']; ?> </option> <?php } } } if ($neededmin < $currentMin && $neededMax <= $currentMin) { if ($neededMin <= $currentMin && $neededMax < $currentMax) { $info = array('roomId' => $roomId, 'checkIn' => $checkIn, 'checkOut' => $currentCheckIn);