0
I needed to consult if a certain date is contained in a date range. Being more specific, in a vehicle control system we have, when we receive a fine, we need to identify the driver who was with a particular vehicle on the day in question.
Example:
$data_saida (registrada quando o veiculo sai)
$data_retorno (registrada quando o veiculo retorna)
$data_infracao = (registrada quando chega a multa)
$placa_veiculo = (registrada quando chega a multa)
What method do I use to confirm according to the time of the violation, who, was with the car by the date, since we have several drivers adastrado? The vehicle was easy as the plate comes in fine and is a unique identifier...
Follow the code I’m running:
<?php
$data = date('Y-m-d');
$hora = date("H:i:s");
$placa = $_POST ['multas'];
$data_i = $_POST ['data_i'];
$hora_i = $_POST ['hora_i'];
$sql = "SELECT * FROM trafego WHERE '$data_i' BETWEEN 'data_s' AND 'data_e' AND placa='$placa'";
$verifica = mysqli_query ($strcon,$sql) or die (mysqli_error());
$row = mysqli_num_rows ($verifica);
if ($row >=1) {
while ($resultado = mysqli_fetch_array($verifica)){
$id_trafego = $resultado ['id_trafego'];
$condutor = $resultado ['condutor'];
$data_s = $resultado ['data_s'];
$hora_s = $resultado ['hora_s'];
$data_e = $resultado ['data_e'];
$hora_e = $resultado ['hora_e'];
echo "<hr/>";
echo $id_trafego;
echo "<br/>";
echo "CONDUTOR: ",$condutor;
echo "<br/>";
echo "DATA SAÍDA: ",date('d/m/Y',strtotime($data_s))," ","HORA DA SAÍDA: ",$hora_s;
echo "<br/>";
echo "DATA RETORNO: ",date('d/m/Y',strtotime($data_e))," ","HORA RETORNO: ",$hora_e;
echo "<hr/>";
echo "<br/>";
echo "<br/>";
}
}else{
echo "<p><h3>Não existe registro de veículos em tráfego na data da multa.<br/>";
echo "Verifique a data digitada, e tente novamente</p></h2>";
}
?>
Excuse me, correcting the last paragraph (put in capital letters the correction): What method do I use to confirm according to DATE of the infringement, who, was with the car, since we have several registered drivers? The vehicle was easy as the plate comes in fine and is a unique identifier...
– Gvian