Ver Mensaje Individual
  #10 (permalink)  
Antiguo 27/08/2012, 20:29
elrey123
 
Fecha de Ingreso: febrero-2009
Mensajes: 61
Antigüedad: 15 años, 3 meses
Puntos: 1
Respuesta: como hacer esta consulta en mysql

Intente comparar las calificaciones antes de guardar en la base de datos, utilizando varios if, pero no da los resultados esperados. aqui esta el archivo dtonde se inserta las calificaciones.

califa.php

Código PHP:
Ver original
  1. <?php require_once('mostrar.php'); ?>
Código HTML:
Ver original
  1. <head><title>prueba de calificaion</title></head>
  2. <form id="form1" name="form1" method="post" action="califa.php">
  3.  <strong>Matricula:</strong><span id="sprytextfield1">
  4.         <input name="txtmatricula" class="boot" type="text" id="txtmatricula"/>
  5.         <span class="textfieldRequiredMsg"></span></span>
  6.          <strong>Parcial: </strong><select name="select" class="boot">
  7.             <option value="Elige">Elige Opci&oacute;n</option>
  8.             <option value="Primer Parcial">Primer Parcial</option>
  9.             <option value="Segundo Parcial">Segundo Parcial</option>
  10.             <option value="Tercer Parcial">Tercer Parcial</option>
  11.             <option value="Cuarto Parcial">Cuarto Parcial</option>
  12.             <option value="Quinto Parcial">Quinto Parcial</option>
  13.           </select>
  14.           <strong>Especialidad:</strong><select name="especialidad" class="boot">
  15.             <option value="Elige">Elige Opci&oacute;n</option>
  16.             <option value="Contabilidad">Contabilidad</option>
  17.             </select>
  18.           <strong>Semestre:</strong><select name="semestre" class="boot">
  19.             <option value="Elige">Elige Opci&oacute;n</option>
  20.             <option value="Primer Semestre">Primer Semestre</option>
  21.             </select>
  22.           <input name="btnbusca" class="boot" type="submit" id="btnbusca" value=" BUSCAR " />
  23.  
  24. </form></center>
Código PHP:
Ver original
  1. <?php
  2.  $especialidad=(isset($_POST['especialidad']) ? $_POST['especialidad'] : null);
  3. $semestre=(isset($_POST['semestre']) ? $_POST['semestre'] : null);
  4.  //especialidades
  5.  $espe='Contabilidad';
  6.  $espe2='Agropecuario';
  7.  $espe3='Informatica';
  8.  //semestres
  9.  $seme1='Primer Semestre';
  10.  $seme2='Segundo Semestre';
  11.  $seme3='Tercer Semestre';
  12.  $seme4='Cuarto Semestre';
  13.  $seme5='Quinto Semestre';
  14.  $seme6='Sexto Semestre';
  15.  
  16.  ?>
  17.  <?php
  18.  if($especialidad == $espe && $semestre == $seme1){
  19.  
  20.  mysql_select_db($database_mostrar, $mostrar);
  21. $query_usuario = "SELECT a.Nombre as Nombre,a.Apellidos as Apellidos,a.Matricula as Matricula,a.Especialidad as Especialidad,g.Semestre as Semestre,g.Grupo as Grupo FROM alumnos a INNER JOIN grupo g on a.Matricula=g.Matricula_A WHERE Matricula='$_POST[txtmatricula]'";
  22. $usuario = mysql_query($query_usuario, $mostrar) or die(mysql_error());
  23. $row_usuario = mysql_fetch_assoc($usuario);
  24. $totalRows_usuario = mysql_num_rows($usuario);
  25.  
  26. $conexion=mysql_connect("localhost","root","matrix") or
  27.   die("Problemas en la conexion");//cambio del password original root
  28. mysql_select_db("califica",$conexion) or
  29.   die("No se selecciono la base de datos");
  30. $registros=mysql_query("select *
  31.                        from mate_contai where Parcial='$_POST[select]' and matricula_alumno='$_POST[txtmatricula]'",$conexion) or
  32. if ($reg=mysql_fetch_array($registros))
  33. {
  34.   ?>
  35.  
  36. <?php
  37. echo "<center><h1 class='Estilo1'>Calificacion de ".$_POST['select']."</h1>";
  38.  
  39. ?>
Código HTML:
Ver original
  1. <table><tr><td class="zebra">
  2. <center><strong>Matricula:</strong> <?php echo $row_usuario['Matricula']; ?> <strong>Nombre:</strong> <?php echo $row_usuario['Nombre']; ?> <?php echo $row_usuario['Apellidos']; ?> <strong>Semestre:</strong> <?php echo $seme1; ?> <strong>Especialidad:</strong> <?php echo $row_usuario['Especialidad']; ?> <strong>Grupo:</strong> <?php echo $row_usuario['Grupo']; ?>
  3. </center>
  4. </td></tr><tr><td class="zebra"><center>
Código PHP:
Ver original
  1. <?php
  2. echo "<form id='form2' name='form2' method='post' action='guardacali.php'>";
  3.  
  4. echo "<input name='matricula' type='hidden' id='matricula' value='$_POST[txtmatricula]'/>";
  5. echo "<input name='parcial' type='hidden' id='parcial' value='$_POST[select]' />";
  6. echo "<input name='especi' type='hidden' id='especi' value='".$row_usuario['Especialidad']."' />";
  7. echo "<input name='semes' type='hidden' id='semes' value='$seme1' />";
  8. echo "<table border=0 width:400px; class='down'>";
  9.  
  10. echo "<tr><td width='50%' class='menumain'>Matematicas</td><td width='50%'><input name='txtmatematicas' class='boot' type='text' id='txtmatematicas' value='".$reg['Matematicas']."'/></td></tr>";
  11.  
  12. echo "<tr><td class='menumain'>Español</td><td> <input name='txtespañol' class='boot' type='text' id='txtespañol' value='".$reg['Espanol']."'/></td></tr>";
  13.  
  14. echo "<tr><td class='menumain'>Informatica</td><td> <input name='txtinformatica' class='boot' type='text' id='txtinformatica' value='".$reg['Informatica']."'/></td></tr>";
  15.  
  16. echo "<tr><td class='menumain'>Ingles</td><td> <input name='txtingles' class='boot' type='text' id='txtingles' value='".$reg['Ingles']."'/></td></tr>";
  17.  
  18. echo "<tr><td class='menumain'>Frances</td><td> <input name='txtfrances' class='boot' type='text' id='txtfrances' value='".$reg['Frances']."'/></td></tr>";
  19.  
  20.  echo "</table> Promedio de ".$_POST['select']." : ".$reg['Promedio']."<br/>";
  21.  ?>
</center></td></tr></table>

Código PHP:
Ver original
  1. <?php
  2.  echo "<hr class='clearFloat' />";
  3.  echo "<p class='alineacionDerecha parrafoCerrar'>";
  4.  echo "<a id='linkCerrar' href='contabilidad.php'><img src='imagenes/maquetado/remove.png' width='32' height='32' alt='Cerrar' title='Cerrar'  /></a></p>";
  5.  echo "<input name='Guardar' class='boot' type='submit' id='Guardar' value=' Guardar ' />";
  6.  echo "<input type='reset' value='Cancelar' id='buttonReset' />  </form>";
  7.  echo "<a href='contabilidad.php'><img src='imagenes/maquetado/folder_previous2.png' height='48' width='48'
  8.         alt='Atras' title='Atras' /></a>";
  9.  
  10.   if($_POST['select']=='Tercer Parcial'){
  11.  
  12.   echo "<center><strong><a href='PromedioGeneral.php'>Obtener Promedio General</a></strong></center>";
  13.  
  14.   }
  15.  
  16. }
  17. else
  18. {
  19.   echo "Matricula no Existe.";
  20. }
  21. mysql_close($conexion);
  22. }
  23. ?>
Código HTML:
Ver original
  1. <p></p>
  2. </body>
  3. </html>