I have the following code to post to a calendar days and times available and for this I use the following routine:
//recebo dados do formulario
//inclusive o dia da semana ex.: Friday
$dia_semana = $_POST['dia_semana'];
$hora = $_POST['hora'];
$laboratorio = $_POST['laboratorio'];
$quantidade = $_POST['quantidade']-1;
//pega a data de hoje
//para verificar qual a proxima data correspondente ao
//dia enviado pelo formulario
// como por exemplo, proxima sexta(Friday)
$hoje = date('Y-m-d');
$dia = date("Y-m-d", strtotime("$hoje next $dia_semana"));
$dados = array(
'data' => $dia,
'hora' => $hora,
'laboratorio' => $laboratorio
);
//cadastra no banco a primeira data usando minha funcao
$cadastrar = DBCreate('nw_vip',$dados);
//faz um loop para cadastrar as proximas datas
//com o dia escolhido limitado a quantidade
//passada pelo formulario
for($i=0;$i<$quantidade;$i++)
{
//se a primeira sexta caiu no dia 10
//caucula as proximas somando 7 dias e cadastrando
$dia = date("Y-m-d", strtotime("$dia +7 day"));
$dados = array(
'data' => $dia,
'hora' => $hora,
'laboratorio' => $laboratorio
);
//cadastra no banco usando e minha função
$cadastrar = DBCreate('nw_vip',$dados);
}
My problem if I post 5 Fridays today and then post another 5 Fridays, it will repeat the dates.
So I would need it the second time I was to release it I could consider the last sixth already registered if there is any and register from it.
Example: Launch 3 Fridays at 8 o'clock:
Sex 24/06 8:00
Sex 01/07 8:00
Sex 08/07 8:00
If I post again later, 5 more than the next one will continue from Friday the 6th. How to make an appointment to know the date of the last Friday already registered, according to my example. Of course it could be another day and another time.