Good morning, who could help me with this.
It is a system to take control of the agenda, for days. What happens is that when I enter a record the first one fits well. from 10 a.m. to 2 p.m., but when I enter another one, I add them again and run them at the end, the 12333 record should start at 3:00 p.m. until 4:00 p.m. and 30125 p.m. from 8:00 p.m. until 10 p.m. .
How could I make the records correspond to each hour ...
$query1 = $mysqli->query("SELECT * FROM calendar WHERE id = 's5' and id_year = '2018' and id_mes = '9'");
while($resultado = mysqli_fetch_array($query1))
{
$p = 0;
for($k= 3;$k<=9;$k++){
if($resultado[$k] != null)
{$mescompleto = $resultado[$k].'/'.$resultado['id_mes'].'/'.$year;}
if($resultado[$k]<10)
{$mescompleto = '0'.$resultado[$k].'/'.$resultado['id_mes'].'/'.$year;}
if($resultado['id_mes']<10){$mescompleto = $resultado[$k].'/'.'0'.$resultado['id_mes'].'/'.$year;}
if($resultado[$k]<10 && $resultado['id_mes']<10){$mescompleto = '0'.$resultado[$k].'/'.'0'.$resultado['id_mes'].'/'.$year;}
if($resultado[$k] == null)
{$mescompleto = "";}
?>
<tr>
<td rowspan="5" scope="row" ><p class="rot inline-block"><?php echo $dias[$p]; ?><br> <?php echo $mescompleto; ?></p></td>
</tr>
<tr>
<td colspan="3"><p class="th">Lavado</p></td>
<?php
$query2 = $mysqli->query("SELECT * FROM tiempo where fecha = '$mescompleto' and id_maq = '1' order by hora_ini ");
$num = mysqli_num_rows($query2);
$xa=0;
$h=1;
while($tiempos = mysqli_fetch_array($query2))
{
$v = $hi = trim(substr($tiempos['hora_ini'],0,-3));
$b = $hf = trim(substr($tiempos['hora_fin'],0,-3));
$tp = $tiempos['fecha'];
$nv = $tiempos['id_nv'];
$com = $tiempos['comentario'];
$idm = $tiempos['id_maq'];
$fecha1 = new DateTime($tiempos['hora_ini']);//fecha inicial
$fecha2 = new DateTime($tiempos['hora_fin']);//fecha de cierre
$intervalo = $fecha1->diff($fecha2);
$intervalo->format('%H h %i m');//00 años 0 meses 0 días 08 horas 0 minutos 0 segundos
if($mescompleto == $tp && $idm == 1)
{
//Aqui agrega los <td>
for($i=1;$i<$x;$i++)
{
echo '<td cospan=""></td>';
}
$s = $intervalo->format('%H') + 1;
?>
<td colspan = "<?php echo $s ?>" >
<div class="progress-bar" style="width:100%;height:20px" onMouseover="fixedtooltip('<?php echo $com?>', this, event, '120px')" onMouseout="delayhidetip()" >
<?php echo $nv; ?>
</div>
</td>
<?php
}
$xa = $x + 1;
$h++;
}
?>
</tr>