Ver Mensaje Individual
  #5 (permalink)  
Antiguo 07/01/2008, 05:25
anacoweb
 
Fecha de Ingreso: febrero-2003
Ubicación: Caracas
Mensajes: 24
Antigüedad: 21 años, 2 meses
Puntos: 0
Re: Test con dos condiciones

Gracias por su aportes... les explico mejor.

ahhh!, olvidense de la línea 148, ahora es la 77, volví a hacer el archivo...

Estoy trabajando directamente desde el dreamweaver. Esto es lo que debo de tener en vista de diseño:




Aqui solo he configurado 3 preguntas para tomarlo como modelo. Si contesto la pregunta No. 1 verdadera, en la base de datos debe llenarse el campo cole1 con el valor de uno (1), si esta pregunta es contestada falsa, debe llenarse el campo flema1 con el valor de uno (1).

Mi duda es que, sabiendo casi nada de php, tengo errores en la condición if.

El error que me da el navegador es:

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in C:\PHP\EasyPHP 2.0b1\www\temp.php on line 77

El código de la línea 77 es:

Código PHP:
<?php    if ($p1=="v"){ 
echo 
"input name="cole1" type="hidden" id="cole1" value=1"}// Esta es la línea 77
        
else {input name="flema1" type="hidden" id="flema1" value=1?>

He creado dos campos invisibles, por los cuales se ingresaran el valor en los campos, cole1, flema1, y aunque no estan aqui elaborados san2, mela2, cole3, mela3 y asi sucesivamente hasta completar las 80 preguntas del test ( que espero separar en 4 páginas -20 preguntas por páginas. Debo de crear para que esto me funcione campos con esos mismos nombres en la base de datos. Otra pregunta: Saben como hacerlo de una manera mas rápida o que no congestione tanto las bases de datos?

Una vez que se llegue al final del test, deben totalizarse los 4 temperamentos, se suman los campos correspondientes de la base de datos, y se compara con otra table para tener el porcentaje de cada temperamento. Ejemplo: Si el temperamento colérico tuvo 10 puntos eso equivale en la tabla maestra a 25%. Y asi con cada temperamento.



Este es el código que me generó dreamweaver, con algunas cositas que le agregue yo luego para personalizar el proyecto:


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 tipos (nombre, p1, p2, p3, cole1, flema1, san2, mela2, cole3, mela3) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['nombre'], "text"),
                       
GetSQLValueString($_POST['p1'], "text"),
                       
GetSQLValueString($_POST['p2'], "text"),
                       
GetSQLValueString($_POST['p3'], "text"),
                       
GetSQLValueString($_POST['cole1'], "text"),
                       
GetSQLValueString($_POST['flema1'], "text"),
                       
GetSQLValueString($_POST['san2'], "text"),
                       
GetSQLValueString($_POST['mela2'], "text"),
                       
GetSQLValueString($_POST['cole3'], "text"),
                       
GetSQLValueString($_POST['mela3'], "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>
</head>

<body>
<form method="post" name="form1" action="<?php echo $editFormAction?>">
  <table border="1" align="center">
    <tr valign="baseline">
      <td nowrap align="right">Nombre:</td>
      <td><input type="text" name="nombre" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Pregunta1:</td>
      <td valign="baseline"><table>
        <tr>
          <td><input name="p1" type="radio" value="v" >
            v</td>
        </tr>
        <tr>
          <td><input name= "p1" type="radio" value="f" >
            f</td>
        </tr>
      </table>
      
<?php    if ($p1=="v"){ 
echo 
"input name="cole1" type="hidden" id="cole1" value=1"}        
else {
input name="flema1" type="hidden" id="flema1" value=1// Esta es la línea 77
?>  
      
         </tr>
    <tr valign="baseline">
      <td nowrap align="right">Pregunta2:</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>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Pregunta3:</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">&nbsp;</td>
      <td><input type="submit" value="Ingresar Respuestas"></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>
</body>
</html>
Agradezco sus sabios comentarios