Ver Mensaje Individual
  #1  
Antiguo 07-03-2012
georkis georkis is offline
Miembro
 
Registrado: abr 2008
Ubicación: Cuba
Posts: 39
Reputación: 0
georkis Va por buen camino
Deseo hacer sumatoria de las horas que calcula el Bucle

Código PHP:
<?php
$server
='localhost';
$username='root';
$pass='konter';
$db='usuario';

if(!
$conn=@mysql_connect($server$username$pass)){
    echo 
'Error al conectarse con MySQL';
}
if(!@
mysql_select_db($db$conn)){
echo 
'Error al seleccionar la base de datos';
}

$sql="SELECT 
  cast(reg_serv.fecha_final as time) AS Hora_salida,
  cast(reg_serv.fecha_inicio as time) AS Hora_entrada
  
FROM
  reg_serv
  "
;
 if(!
$result=@mysql_query($sql$conn)){
     echo 
'Error en la consulta';
     }
 
$row=mysql_fetch_array($result);
?>
<table>
<tr>
    <td>Resultado</td>
    
</tr>
<?php

do { ?>
 <tr>
     
     <td><?php echo $total=date("H:i:s"strtotime("00:00:00") + strtotime($row['Hora_salida']) - strtotime($row['Hora_entrada'])); ?></td>
     
 </tr>
<?php }while($row=mysql_fetch_array($result)); ?>
</table>
Total horas:<?php  // poner el total ?>
<?php
mysql_free_result
($result);
?>

Última edición por ecfisa fecha: 07-03-2012 a las 20:04:56. Razón: ETIQUETAS: [PHP] [/PHP]
Responder Con Cita