Ver Mensaje Individual
  #13 (permalink)  
Antiguo 28/01/2014, 13:53
Avatar de adryan310
adryan310
 
Fecha de Ingreso: septiembre-2012
Mensajes: 450
Antigüedad: 12 años, 5 meses
Puntos: 3
Exclamación Respuesta: Como guardar el dato anterior de un while + php ?

Amigo ahorita lo tengo asi, y me sale todo menos los campos calculados osea los que sumamos,
Código PHP:
while($dataGames $strDataGames->fetch(PDO::FETCH_ASSOC)){
    if(isset(
$anterior) &&  ($dataGames['NumGame']  == $anterior['NumGame'])&&  ($dataGames['Teams']    == $anterior['Teams'])){
                            
// Aca haces lo que quieras.
                           
if(strtotime($anterior['Time']) < strtotime($dataGames['Time']))
                               
$anterior['Time']     =  $dataGames['Time'];
                               
$anterior['Score']    =  $dataGames['Score'];
                               
$counterTickets      +=  $dataGames['Tickets'];
                               
$counterRisk         +=  $dataGames['Risk'];
                               
$counterWinLoss      +=  $dataGames['WinLoss'];
                               
$IdGames             .=  $dataGames['IdGame']."+";
                            }elseif(isset(
$anterior)){
                                    
// Si no es el primer resultado.
                                    
                                    
$todayFigure += $counterWinLoss;
                                    
$response .= "<tr>
                                                <td>$anterior[Time]</td>
                                                <td>$anterior[NumGame]</td>
                                                <td>$anterior[Teams]</td>
                                                <td>$anterior[Score]</td>
                                                <td><a href=\"#\" onClick=\"openInfoWager(this);\">$counterTickets</a></td>
                                                <td>$counterRisk</td>
                                                <td>$counterWinLoss</td>
                                                <td>$todayFigure</td>
                                            </tr>"
;
      }
                                
                                
// Preparar las variables para la proxima ronda.
                                
$counterTickets     0;
                                
$counterRisk        0;
                                
$counterWinLoss     0;
                                
$IdGames            "";
                                
$anterior           $dataGames;
    
}
//end while