Ver Mensaje Individual
  #5 (permalink)  
Antiguo 28/01/2014, 16:21
Avatar de adryan310
adryan310
 
Fecha de Ingreso: septiembre-2012
Mensajes: 450
Antigüedad: 11 años, 8 meses
Puntos: 3
Exclamación Respuesta: Como realizar la suma de los siguientes campos dentro del while?

Amigos, asi tengo mi codigo actualmente, este realiza la suma de los datos pero no se por que lo hace mal, y a Alexis88 amigo no te entendi bien lo que me comentastes.
Mi codigo:
Código PHP:
while($dataGames $strDataGames->fetch(PDO::FETCH_ASSOC)){
                           if(isset(
$anterior) && ($dataGames['NumGame']  == $anterior['NumGame']) && ($dataGames['Teams'] == $anterior['Teams'])){
                               if(
strtotime($anterior['Time']) < strtotime($dataGames['Time']))
                                  
$anterior['Time'] = $dataGames['Time'];
                               elseif(
strtotime($anterior['Time']) > strtotime($dataGames['Time']) || strtotime($anterior['Time']) == strtotime($dataGames['Time']))
                                  
$anterior['Time'] = $anterior['Time'];
                               
                               
$anterior['Score']    =  $dataGames['Score'];
                               
$anterior['Tickets'] =  $anterior['Tickets'] + $dataGames['Tickets'];
                               
$anterior['Risk'] =  $anterior['Risk'] + $dataGames['Risk'];
                               
$anterior['WinLoss'] =  $anterior['WinLoss'] + $dataGames['WinLoss'];
                               
                            }elseif(isset(
$anterior)){
                                    
$todayFigure $todayFigure $anterior['WinLoss'];
                                    
$response .= "<tr>
                                                   <td>$anterior[Time]</td>
                                                   <td>$anterior[NumGame]</td>
                                                   <td>$anterior[Teams]</td>
                                                   <td>$anterior[Score]</td>
                                                   <td><a href=\"#\" onClick=\"openInfoWager(this);\">$anterior[Tickets]</a></td>
                                                   <td>$anterior[Risk]</td>
                                                   <td>$anterior[WinLoss]</td>
                                                   <td>$todayFigure</td>
                                                  </tr>"
;
                            }
                                
                                
// Preparar las variables para la proxima ronda.
                                
$anterior['Tickets'] =  0;
                                
$anterior['Risk']    =  0;
                                
$anterior['WinLoss'] =  0;
                                
$anterior           $dataGames;
    
}
//end while