Ver Mensaje Individual
  #5 (permalink)  
Antiguo 07/03/2010, 16:29
Avatar de Mahishasura
Mahishasura
 
Fecha de Ingreso: enero-2010
Ubicación: En las profundidades del cosmos
Mensajes: 58
Antigüedad: 14 años, 3 meses
Puntos: 4
Respuesta: problemas con el submit T_T HELP

Puede que tengas un problema con la comparación de fechas...
Código PHP:
<?php
require('Connections/db-cnx.php');
    
$not_ID $_GET['not_ID']; 
   
    
$row=mysql_fetch_array(mysql_query("select * from apuesta where id_a='".$not_ID."'"));
    
$bet1 $row['bet1'];
    
$bet2 $row['bet2'];
    
$empate $row['empate'];
    
$fec_fin $row['fec_fin'];

    
$fecha_actual=strtotime(date('Y-m-d H:i:s'));
    
$fecha_final=strtotime($fec_fin);

if(
$fecha_final <= $fecha_actual){
//Si ya terminó el partido

    
$raw=mysql_fetch_array(mysql_query("select * from detalle_a where id_a='".$not_ID."'"));
    
$cant $raw['cantidad'];
    
$id $raw['id'];
        
        if(
$_GET['do']=='pagar'){
            
$gano $_POST['radio'];

            if(
$gano == "local")
            {
            
$win floor(((($bet2+$empate)/$bet1)*$cant)+$cant);
            
$q "update tz_members set puntos = puntos + ".$win." where id='".$id."' and apuesta = 'local'"
                
mysql_query($q) or die(mysql_error());
            }
            if(
$gano == "visita")
            {
            
$win floor(((($bet1+$empate)/$bet2)*$cant)+$cant);
            
$q "update tz_members set puntos = puntos + ".$win." where id='".$id."' and apuesta = 'visita'"
                
mysql_query($q) or die(mysql_error());
            }
            if(
$gano == "empate")
            {
            
$win floor(((($bet1+bet2)/$empate)*$cant)+$cant);
            
$q "update tz_members set puntos = puntos + ".$win." where id='".$id."' and apuesta = 'empate'"
                
mysql_query($q) or die(mysql_error());
            }
            
            
            
$qq "update apuesta set estado = 1 where id_a='".$not_ID."'"
                
mysql_query($qq) or die(mysql_error());
            
$qqq "update detalle_a set ganancia = ".$win." where id_a='".$not_ID."' and id='".$id."'"
                
mysql_query($qqq) or die(mysql_error());
                
                echo 
"<script> alert (\"Las Apuestas fueron Pagadas.\"); </script>";
                echo 
"<script language=Javascript> location.href=\"panel_apuesta.php\"; </script>";
            
            }
} else {
echo 
"Todavia no finaliza el Partido"; }
?>
        <form action="?do=pagar" method="post">
        <input type="radio" name="radio" value="local" /><?php echo $row['equipo1']; ?><br />
        <input type="radio" name="radio" value="visita" /><?php echo $row['equipo2']; ?><br />
        <input type="radio" name="radio" value="empate" /> EMPATE !<br />
        <input type="submit" name="submit" value="pagar" />
        </form>
Cambié el formato de la hora, de "h" a "H" Así podrás tener un cálculo mucho más preciso.
Lo que hice fue simplemente convertir la fecha actual a tiempo Unix, investiga si te interesa.
Al momento de guardar la fecha en la columna fec_fin, deberás cambiar el formato de la Hora también, por que si la dejas en "h" obtendrás 05, en cambio con "H" obtendrás 17
Saludos

Última edición por Mahishasura; 07/03/2010 a las 16:34