-1
I am developing a system for scheduling reservations of locations and equipment for users registered in this system, which in case are teachers, reserve such items for their classes: the teacher logs in the system, chooses the equipment and location and chooses a free date and time to make use of this reservation.
I’m trying to make sure that the same user can’t book more than 3 times in the same week, this being the week from Monday to Saturday. I tried to do with several PHP and SQL functions (Mysql) but did not have any success.
Here is the structure of my SQL table:
CREATE TABLE agend_reservas (
ID_AGENDAMENTO bigint(20) NOT NULL,
LOCAL1 int(11) DEFAULT NULL,
LOCAL2 int(11) DEFAULT NULL,
LOCAL3 int(11) DEFAULT NULL,
LOCAL4 int(11) DEFAULT NULL,
LOCAL5 int(11) DEFAULT NULL,
LOCAL6 int(11) DEFAULT NULL,
LOCAL7 int(11) DEFAULT NULL,
LOCAL8 int(11) DEFAULT NULL,
LOCAL9 int(11) DEFAULT NULL,
LOCAL10 int(11) DEFAULT NULL,
LOCAL11 int(11) DEFAULT NULL,
LOCAL12 int(11) DEFAULT NULL,
LOCAL13 int(11) DEFAULT NULL,
EQUIPAMENTO1 int(11) DEFAULT NULL,
EQUIPAMENTO2 int(11) DEFAULT NULL,
EQUIPAMENTO3 int(11) DEFAULT NULL,
EQUIPAMENTO4 int(11) DEFAULT NULL,
EQUIPAMENTO5 int(11) DEFAULT NULL,
EQUIPAMENTO6 int(11) DEFAULT NULL,
EQUIPAMENTO7 int(11) DEFAULT NULL,
EQUIPAMENTO8 int(11) DEFAULT NULL,
EQUIPAMENTO9 int(11) DEFAULT NULL,
EQUIPAMENTO10 int(11) DEFAULT NULL,
INTERNET varchar(3) NOT NULL,
RESERVADO_PARA varchar(60) NOT NULL,
RESERVA_PARA_DATA date NOT NULL,
HORA_INICIO time NOT NULL,
HORA_FIM time NOT NULL,
RESERVADO_NA_DATA date NOT NULL,
OBSERVACAO text
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Here is the structure of my table, the field RESERVA_PARA_DATA
is the date the user will use the reservation, the field RESERVADO_NA_DATA
is the current date of the server that the user made the reservation - that date doesn’t matter - and the field RESERVADO_PARA
is the name of the user who is booking.
A Count in the bank according to your criteria within the week in question no longer helps you ?
– 8biT
I’m not getting to know what to use in Where to be able to filter in what week should the check take place.
– Lucas Barbosa Fonseca
Add in the question the structure of your table. Without this it is difficult to help. Already in advance you should probably have a Date field in your table with your reservations, with this just make a
count
within the current week that will return the amount of records found. With this validate if the return is greater than X times.– 8biT
@Lucasbarbosafonseca Add the code to make it easier for us to help
– Anderson Henrique
I edited the question
– Lucas Barbosa Fonseca