0
I would like to search the database for all records according to the "DOCTOR" between two dates DATA_INICIAL
and DATA_FINAL
No repeat records of the day.
CURRENT RESULT:
BRUNO BARBOSAS 02/04/2018 12:18 02/04/2018 12:18
BRUNO BARBOSAS 02/04/2018 12:22 02/04/2018 12:22
BRUNO BARBOSAS 09/04/2018 08:26 09/04/2018 08:26
BRUNO BARBOSAS 09/04/2018 08:30 09/04/2018 08:30
I WISH YOU WOULD JUST SHOW:
BRUNO BARBOSAS 02/04/2018 12:18 02/04/2018 12:22
BRUNO BARBOSAS 09/04/2018 08:26 09/04/2018 08:30
CODE:
$nome= $_POST['nome'];
$data_i = $_POST['data_inicio'];
$data_f = $_POST['data_fim'];
$consulta= "SELECT * FROM $tabela
WHERE medico = '$medico'
AND data >= '$data_i'
AND data <= '$data_f' ";
$resultado = mysqli_query($conn, $consulta);
while($rows_registro = mysqli_fetch_array($resultado)){
echo $rows_registro['nome'];
echo $rows_registro['data']; //Aqui tem que vir o PRIMEIRO registro do dia sem repetir
echo $rows_registro['data']; //Aqui tem que vir o ULTIMO registro do dia sem repetir
}
After searching between the two dates I would like to show the first record and the last one for each DAY without repeating as shown in the above example of how I would like the result.
Perfect, that’s what I really wanted, I got the results right, I only had a problem to fit in the condition where you will only search when it is equal to the chosen NAME and DATA_INIAL and DATA_FINAL. I tried with using >= AND <= besides BETWEEN:<br> <code> WHERE name= '$name' AND data >= '$data_i' AND data <= '$data_f' "</code> The result is blank even if you put the existing date in the database, which is what is happening. That’s all I need to finish my project.
– profnv
@profnv example with date range and name: http://sqlfiddle.com/#! 9/d3d96e/3
– Bacco
perfect, thanks even, saved the day
– profnv