Código PHP:
<?php require_once('Connections/Apuesta.php');
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE apuestas SET fecha=%s, hora=%s, evento=%s, deporte=%s, usuario=%s, cuota=%s, seleccion=%s, resultado=%s, comentario=%s WHERE id=%s",
GetSQLValueString($_POST['fecha'], "date"),
GetSQLValueString($_POST['hora'], "text"),
GetSQLValueString($_POST['evento'], "text"),
GetSQLValueString($_POST['deporte'], "text"),
GetSQLValueString($_POST['usuario'], "text"),
GetSQLValueString($_POST['cuota'], "text"),
GetSQLValueString($_POST['seleccion'], "text"),
GetSQLValueString($_POST['resultado'], "text"),
GetSQLValueString($_POST['comentario'], "text"),
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_Apuesta, $Apuesta);
$Result1 = mysql_query($updateSQL, $Apuesta) or die(mysql_error());
$updateGoTo = "Edicionpicks.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_Recordset1 = "-1";
if (isset($_GET['recordID'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
}
mysql_select_db($database_Apuesta, $Apuesta);
$query_Recordset1 = sprintf("SELECT * FROM apuestas WHERE id = %s ORDER BY id DESC", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $Apuesta) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$maxRows_DetailRS1 = 50;
$pageNum_DetailRS1 = 0;
if (isset($_GET['pageNum_DetailRS1'])) {
$pageNum_DetailRS1 = $_GET['pageNum_DetailRS1'];
}
$startRow_DetailRS1 = $pageNum_DetailRS1 * $maxRows_DetailRS1;
mysql_select_db($database_Apuesta, $Apuesta);
$recordID = $_GET['recordID'];
$query_DetailRS1 = "SELECT * FROM apuestas WHERE id = $recordID ORDER BY id DESC";
$query_limit_DetailRS1 = sprintf("%s LIMIT %d, %d", $query_DetailRS1, $startRow_DetailRS1, $maxRows_DetailRS1);
$DetailRS1 = mysql_query($query_limit_DetailRS1, $Apuesta) or die(mysql_error());
$row_DetailRS1 = mysql_fetch_assoc($DetailRS1);
if (isset($_GET['totalRows_DetailRS1'])) {
$totalRows_DetailRS1 = $_GET['totalRows_DetailRS1'];
} else {
$all_DetailRS1 = mysql_query($query_DetailRS1);
$totalRows_DetailRS1 = mysql_num_rows($all_DetailRS1);
}
$totalPages_DetailRS1 = ceil($totalRows_DetailRS1/$maxRows_DetailRS1)-1;
$usuario=$row_DetailRS1['usuario'];
mysql_select_db($database_Apuesta, $Apuesta);
$query_Recordset2 = "SELECT * FROM concursantes WHERE usuario = '$usuario' AND puntuacion";
$Recordset2 = mysql_query($query_Recordset2, $Apuesta) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?>
Código PHP:
<select name='resultado'>
<option value='<?php echo $row_DetailRS1['resultado']; ?>'><?php echo $row_DetailRS1['resultado']; ?></option>
<option value='ACERTADO''<?php
$puntos=$row_Recordset2['puntuacion'];
$cuota=$row_Recordset1['cuota'];
$variable_a_sumar=($cuota/10);
$suma=$row_Recordset2['puntuacion']+$variable_a_sumar;
mysql_query("UPDATE concursantes SET puntuacion=$suma WHERE usuario = '$usuario' AND puntuacion=$puntos");
?>'>ACERTADO </option>
<option value='FALLADO''<?php
$puntos=$row_Recordset2['puntuacion'];
$cuota=$row_Recordset1['cuota'];
$variable_a_sumar=($cuota/10);
$suma=(($row_Recordset2['puntuacion'])-($variable_a_sumar));
mysql_query("UPDATE concursantes SET puntuacion=$suma WHERE usuario = '$usuario' AND puntuacion=$puntos");
?>'>Fallado </option>
<option value='ANULADO'>Anulado </option>
<option value='PENDIENTE'>Pendiente</option>
</select>
Código PHP:
<option value='ACERTADO''<?php
$puntos=$row_Recordset2['puntuacion'];
$cuota=$row_Recordset1['cuota'];
$variable_a_sumar=($cuota/10);
$suma=$row_Recordset2['puntuacion']+$variable_a_sumar;
mysql_query("UPDATE concursantes SET puntuacion=$suma WHERE usuario = '$usuario' AND puntuacion=$puntos");
?>'>ACERTADO </option>
Si intento restar no me deja, aplico la siguiente formula
Código PHP:
<option value='FALLADO''<?php
$puntos=$row_Recordset2['puntuacion'];
$cuota=$row_Recordset1['cuota'];
$variable_a_sumar=($cuota/10);
$suma=(($row_Recordset2['puntuacion'])-($variable_a_sumar));
mysql_query("UPDATE concursantes SET puntuacion=$suma WHERE usuario = '$usuario' AND puntuacion=$puntos");
?>'>Fallado </option>
Código PHP:
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
Se que no va aqui, pero aprovecho, en Mysql el campo puntuacion lo tengo como float y con atributo UNSIGNED, como tengo que ponerlos para que acepte decimales hasta tres cifras y que pueda ser un numero en negativo
Muchas gracias por vuestra ayuda, haber si me entero que llevo toda la tarde con la cabeza loca con esto