![sonriente](http://static.forosdelweb.com/fdwtheme/images/smilies/smile.png)
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 = new DateTime();
$actual = $fecha->format('Y/m/d h:i:s');
//si la hora actual ya paso el tiempo final
if($fec_fin < $actual){
$raw=mysql_fetch_array(mysql_query("select * from detalle_a where id_a='".$not_ID."'"));
$cant = $raw['cantidad'];
$id = $raw['id'];
if($_POST['submit']=='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>";
}
?>
<form action="" 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>
<?php
}else
echo "Todavia no finaliza el Partido";
?>