How can I place the result of the $ query5 within the table that already exists, that is, put a new column to that table with this result, and also how can I title each column?
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST'){
$conexion = mysqli_connect("localhost", "root", "","henkel");
$consulta ="SELECT DISTINCT* FROM lote where Etapa=11 and Equipo = 2 or 5 or 4 order by HoraFinal DESC limit 50";
$consulta2 ="SELECT DISTINCT * FROM lote where Etapa = 1 and Equipo = 2 or 5 or 4 ORDER BY HoraInicio DESC limit 20";
$consulta5 ="SELECT DISTINCT time_to_sec(timediff( MIN( HoraInicio ), MAX( HoraFinal ))) / 3600 FROM lote GROUP BY Lote'";
if ($conexion -> connect_errno){
die("Fallo la conexion:(".$conexion -> mysqli_connect_errno().")".$conexion-> mysqli_connect_error());
}
if(ISSET($_POST['btnActualizar'])){
$resconexion= mysqli_query($conexion,$consulta);
$resconexion3= mysqli_query($conexion,$consulta5);
}
if(ISSET($_POST['btncomp'])){
$resconexion2= mysqli_query($conexion,$consulta2);
}
//$cont3= mysqli_fetch_array($resconexion3);
}
?>
<!doctype html>
<html lang="es">
<form action ="Reportes.php" method ="post">
<head>
<title>Lotes</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body>
<h2>Lotes terminados </h2>
<?php ///dentro de aqui quiero poner el resultado de $consulta5
if (isset($resconexion) ){
echo"<h2>lotes ter</h2> <table>" ;
while($cont1=mysqli_fetch_array($resconexion)){
echo
'<tr>'.
'<th>'.$cont1['Lote'].'</th>'.
'<th>'.$cont1['IDH'].'</th>'.
'<th>'.$cont1['NumOrden'].'</th>'.
'<th>'.$cont1['Operador'].'</th>'.
'<th>'.$cont1['Equipo'].'</th>'.
'<th>'.$cont1['Etapa'].'</th>'.
'<th>'.$cont1['HoraFinal'].'</th>'.
'</tr>';
}
echo"</table>";
}
?>
<?php
if (isset($resconexion2)){
echo"<h2>comparacion</h2> <table>" ;
while($cont2=mysqli_fetch_array($resconexion2)){
echo
'<tr>'.
'<th>'.$cont2['Lote'].'</th>'.
'<th>'.$cont2['IDH'].'</th>'.
'<th>'.$cont2['NumOrden'].'</th>'.
'<th>'.$cont2['Operador'].'</th>'.
'<th>'.$cont2['Equipo'].'</th>'.
'<th>'.$cont2['Etapa'].'</th>'.
'<th>'.$cont2['HoraInicio'].'</th>'.
'</tr>';
}
echo"</table>";
}
?>
<tr>
<td><input type = "submit" name = "btnActualizar" value = "Actualizar"></td>
</tr>
<tr>
<td><input type ="submit" name= "btncomp" value= "Comparar"></td>
</tr>
</body>
</form>
</html>