LO HE SOLUCIONADO ASI, POR SI A ALGUIEN LE INTERSA...
SALUDOS...
Código PHP:
// PRIMERO GUARDO LOS VALORES PARCIALES EN UN ARRAY...
$sql=$consultar_historial." where id_incidencia = '$id' ORDER BY h.id";
$consulta=mysql_query($sql);
$c=0;
$f=0;
$fecha_hoy= time();
$fecha=date(Y."-".m."-".d." ".h.":".i.":".s,$fecha_hoy);
$fecha_cierre=0;
$fecha_pausada_parcial=0;
$fecha_abierta_parcial=0;
$total_parcial= array();
while($array=mysql_fetch_array($consulta)){
if($c==0){
$color="f4f4f4";
$c++;
}else{
$color="ffffff";
$c=0;
}
if ($array[estados]=="Abierta" && $f==0){
$fecha_apertura=$array[fecha];
$f=1;
}elseif($array[estados]=="Pausada"){
$fecha_pausada_parcial=$array[fecha];
}elseif($array[estados]=="Abierta"){
$fecha_abierta_parcial=$array[fecha];
if($fecha_pausada_parcial!=0){
$diff="SELECT TIMEDIFF('".$fecha_abierta_parcial."','".$fecha_pausada_parcial."');";
$consu=mysql_query($diff);
$parcial=mysql_fetch_array($consu);
$total_parcial[]=$parcial[0];
$fecha_pausada_parcial=0;
}
}elseif($array[estados]=="Cerrada"){
$fecha_cierre=$array[fecha];
}
}
//LUEGO SUMO LOS VALORES Y HAGO LAS CONSULTAS....
if ($fecha_cierre!=0){
$fecha=$fecha_cierre;
}
$total=count($total_parcial);
if ($total>=2){
$contador=0;
$total_fecha=0;
for ($i=0; $i < $total ; $i++){
if ($contador==0){
$fecha_parcial=$total_parcial[$i];
$contador++;
}elseif($total_fecha!=0){
$fecha_parcial=$total_parcial[$i];
$suma_fecha="SELECT ADDTIME('".$total_fecha."','".$fecha_parcial."')";
$query_fecha=mysql_query($suma_fecha);
$array_query_fecha=mysql_fetch_array($query_fecha);
$total_fecha=$array_query_fecha[0];
}else{
$fecha_parcial2=$total_parcial[$i];
$suma_fecha="SELECT ADDTIME('".$fecha_parcial2."','".$fecha_parcial."')";
$query_fecha=mysql_query($suma_fecha);
$array_query_fecha=mysql_fetch_array($query_fecha);
$total_fecha=$array_query_fecha[0];
}
}
$valor_total=$total_fecha;
}else{
$valor_total=$total_parcial[0];
}
//Consulta a la tabla incidenicas, traigo fecha carga...
$sql=$incidencias_abiertas." WHERE i.id = '$id'";
$query_respuesta=mysql_query($sql);
$array_respuesta=mysql_fetch_array($query_respuesta);
$fecha_carga=$array_respuesta[fecha_carga];
//Tiempo de Respuesta
$sql="SELECT TIMEDIFF('".$fecha_apertura."','".$fecha_carga."')";
$consulta_diferencia=mysql_query($sql);
$array_diferencia=mysql_fetch_array($consulta_diferencia);
echo "<strong>Tiempo de Respuesta: </strong>".$array_diferencia[0]." | ";
echo "<strong>Total tiempo pausado: </strong>".$valor_total." | ";
//Total de la incidencia desde la carga, hasta el cierre..
$diferencia="SELECT TIMEDIFF('".$fecha."','".$fecha_carga."')";
$queryss=mysql_query($diferencia);
$arrays=mysql_fetch_array($queryss);
//Total tiempo abierto parcial
$d="SELECT TIMEDIFF('".$fecha."','".$fecha_apertura."')";
$q=mysql_query($d);
$a=mysql_fetch_array($q);
//total tiempo abierto completo
$d1="SELECT TIMEDIFF('".$a[0]."','".$valor_total."')";
$q1=mysql_query($d1);
$a1=mysql_fetch_array($q1);
echo "<strong>Total tiempo abierto: </strong>".$a1[0]." | ";
echo "<strong>Total tiempo incidencia:</strong>".$arrays[0];
desconectar();
aI ALGUIEN PUEDE HACER LO MISMO DE MEJOR MANERA... AVISE, QUE ME HE ENREDADO MUCHISIMO CON ESTE CODIGO... GRACIAS...