My intention is to list a series of products, specifying a range of dates of reservation intention, and filtering the products not yet reserved.
$comprobar_reservas_disponibilidad = mysqli_query($con,"SELECT DISTINCT flotaid
FROM disponibilidad
WHERE ('$fecha_inicio' BETWEEN DESDE AND HASTA) AND ('$fecha_fin' BETWEEN DESDE AND HASTA) ORDER BY flotaid");
$comprobar_prereservas = mysqli_query($con,"SELECT DISTINCT flotaid
FROM prereserva
WHERE ('$fecha_inicio' BETWEEN DESDE AND HASTA) AND ('$fecha_fin' BETWEEN DESDE AND HASTA) ORDER BY flotaid");
Imagine that the information of the two queries is stored in an array from which the info is extracted.
I use two queries because each of them belongs to a table. In both of them there is reservation information, but each one is filled in one way, that's the same.
How is it possible to query the correct result for a small date range, but not for a large one? The listed result should only be smaller and smaller, since a longer range of dates covering products already booked is requested, is not it?
I use three tables, "pre-book" and "availability" , which are used to store booking data, and "fleet" , where the descriptive information of the ships is stored..name, characteristics, model..etc. The data of the user who makes the reservation from the web, are saved in "pre-booking" until a few days pass or the admin of the web passes it through another program to the table "availability", which is the definitive reservations.I need fill in "pre-booking" with the data of the range of dates to reserve, boat, user to reserve.
step link to complete file: "Complete code"
and image of what a range of dates returns: link
example : boats not available between the days of 11/25/2016 and 11/25/2016: Ids 8,15,17, so the others are listed, those available
What I need in a query (which I will use twice) to get the ids of the boats AVAILABLE, and filter the NOT AVAILABLE, which will be shown in a print / echo to know what has been filtered.