Gracias por su tiempo...Entiendo la lógica de lo que me quieres decir pero ...estuve todo el dia de ayer ( tarde y noche), y parte de esta mañana, y no me funciona... disculpa mi ignorancia en esto
Cree dos tablas, una llamada preguntas
Esta información la ingrese por el archivo, cuyo código esta al final de este comentario.
y la otra, temperamentos
![](http://www.carrypc.net/temperamentos.jpg)
La información que esta en esta tabla la inclui directamente en la propia base de datos de phpadmin.. configure la estructura de los campos de los temperamentos como tinyint
Y coloque el codigo para actualizar e incluir en la tabla temperamentos que me comentastes pero no guarda en esta tabla....
Código PHP:
<?php
if( $p1 == 'v' ){
mysql_query("UPDATE temperamentos SET colerico=colerico+1");
}else{
mysql_query("UPDATE temperamentos SET flematico=flematico+1");
}
Debo de relacionar una tabla con la otra para que esto me funcione? Como lo hago?
En que parte del documento va el código de actualizar, antes o después del form?
Es obligatorio colocar en dos tablas para que haga esto, porque si la coloco en una puedo llevar de una manera mas fácil la sesion de la persona que esta haciendo el test
Por lo poco que se de php, me es mas facil meterla variable en un campo oculto pero recuerda que este codigo este error en el navegador:
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in C:\PHP\EasyPHP 2.0b1\www\temp.php on line 77
Y la linea de código 77 es:
Código PHP:
if ($p1=='v'){
echo "input name="colerico" type="hidden" id="colerico" value=1";
}
Este código que esta arriba, ya no lo tengo en el archivo por este error.
Te coloco el código actual del archivo que estoy usando:
Código PHP:
<?php require_once('Connections/temperamentos.php'); ?>
<?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_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO preguntas (nombres, email, p1, p2, p3) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['nombres'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['p1'], "text"),
GetSQLValueString($_POST['p2'], "text"),
GetSQLValueString($_POST['p3'], "text"));
mysql_select_db($database_temperamentos, $temperamentos);
$Result1 = mysql_query($insertSQL, $temperamentos) or die(mysql_error());
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10; }
-->
</style>
</head>
<body>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table border="1" align="center">
<tr valign="baseline">
<td nowrap align="right">Nombres:</td>
<td><input type="text" name="nombres" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Email:</td>
<td><input type="text" name="email" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><p>Pregunta 1. (p1)</p>
<p>:</p></td>
<td valign="baseline"><table>
<tr>
<td><input type="radio" name="p1" value="v" >
v</td>
</tr>
<tr>
<td><input type="radio" name="p1" value="f" >
f</td>
</tr>
</table></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><p>Pregunta 1. (p2):</p>
<p> </p></td>
<td valign="baseline"><table>
<tr>
<td><input type="radio" name="p2" value="v" >
v</td>
</tr>
<tr>
<td><input type="radio" name="p2" value="f" >
f</td>
</tr>
</table></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><p>Pregunta 1. (p3):</p>
<p> </p></td>
<td valign="baseline"><table>
<tr>
<td><input type="radio" name="p3" value="v" >
v</td>
</tr>
<tr>
<td><input type="radio" name="p3" value="f" >
f</td>
</tr>
</table></td>
<?php
if( $p1 == 'v' ){
mysql_query("UPDATE temperamentos SET colerico=colerico+1");
}else{
mysql_query("UPDATE temperamentos SET flematico=flematico+1");
}
?>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Insert record"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
</body>
</html>
Agradezco tu tiempo y tu tutoria....soy un aprendiz en esto