Ver Mensaje Individual
  #3 (permalink)  
Antiguo 14/07/2015, 08:06
diegodelpiero
 
Fecha de Ingreso: mayo-2015
Mensajes: 53
Antigüedad: 9 años
Puntos: 0
Respuesta: poner contador a pagina y que envíe registros a mysql.

he realizado lo que me comentas pero no me funciona.

Código Javascript:
Ver original
  1. <style type="text/css">
  2. .centrado {
  3.     width: 240px;
  4.     margin: 0 auto;
  5.     text-align: center;
  6.     border: 1px solid #444;
  7.     font-family: Arial, Helvetica, sans-serif;
  8.     font-size: 13px;
  9.     padding: 6px;
  10.     background-color: #ffc;
  11. }
  12. </style>
  13.  
  14. <script type="text/javascript">
  15. <!--
  16. var targetURL="cursos.php" //página que se abrirá al finalizar el conteo
  17. var countdownfrom=5 //tiempo en segundos de la cuenta atrás
  18. var currentsecond=document.redirect.destino.value=countdownfrom+1
  19. function countredirect(){
  20. if (currentsecond!=1){
  21. currentsecond-=1
  22. document.presentar.destino.value=currentsecond
  23. }
  24. else{
  25. window.location=targetURL
  26.  
  27. return
  28. }
  29. setTimeout("countredirect()",1000)
  30. }
  31. countredirect()
  32. //-->
  33. </script>
  34. </form>
  35. </body>

esto es el resto de código que tengo, ya ya puse el inpuy text :

Código PHP:
Ver original
  1. <?php
  2. @$tematicaId=$_GET['tematicasId'];
  3. @$usuario=$_SESSION['MM_Username'];
  4. @$sql5 = "SELECT estudianteId, tematicaId FROM notas WHERE tematicaId='".$tematicaId."' and estudianteId='".$usuario."'";
  5. @$result = mysql_query($sql5) or die(mysql_error());
  6. @$iNumReg = mysql_num_rows($result);
  7. if ($iNumReg>0)
  8. {
  9.     while ($rowEmp = mysql_fetch_assoc($result))
  10.     {
  11.         @$usuconsulta = $rowEmp['estudianteId'];
  12.         @$idconsulta = $rowEmp['tematicaId'];
  13.         if ($tematicaId==$idconsulta && $usuario==$usuconsulta)
  14.         {
  15.             echo"Ya presentaste tu evaluacion";
  16.             echo "<br/>";
  17.             $prueba=0;
  18.         }
  19.     }
  20. }
  21. else
  22. {
  23.    
  24.     if (isset($_GET['tematicasId']) && !isset($_POST['submit']))
  25.     {
  26.         @$aux=$_GET['tematicasId'];
  27.         @$var=$row_Recordset1['tematicasId'];
  28.         if ($aux==$var)
  29.         {
  30.             $sTematica=$row_Recordset1['tematicasId'];
  31.             $show='0';
  32.             @$respuestas=$_POST['respuesta'];
  33.             $prueba=1;
  34.         }
  35.         else
  36.         {
  37.             echo "Aun no se ha subido una evaluacion";
  38.             echo "<br/>";
  39.             $prueba=0;
  40.         }
  41.     }
  42.     else
  43.     {      
  44.         if (isset($_POST['submit']))
  45.         {
  46.             @$aux=$_GET['tematicasId'];
  47.             @$sTematica=$row_Recordset1['tematicasId'];
  48.             @$respuestas=$_POST['respuesta'];
  49.             @$show='1';
  50.             $prueba=1;
  51.            
  52.         }
  53.         else
  54.         {
  55.             echo "No se ha especificado una tematica de la evaluacion";
  56.             exit;
  57.         }
  58.     }
  59. }
  60. ?>
  61. <?php
  62. if (@$prueba==1)
  63. {
  64. @$sql = "SELECT * FROM evaluaciones WHERE tematicasId='".$aux."'";
  65. @$result = mysql_query($sql) or die(mysql_error());
  66. @$iNumReg = mysql_num_rows($result);
  67.  
  68. ?>
  69. <table width="615" border="1">
  70.     <form action='' method='post' name="presentar" >
  71.         <?php
  72.         if (@$show=='0')
  73.         {
  74.             if ($iNumReg>0)
  75.             {
  76.                 $i = 0;  
  77.                 while ($rowEmp = mysql_fetch_assoc($result))
  78.                 {
  79.                     @$dbpregunta = $rowEmp['evaluacionPregunta'];
  80.                     @$dbR1=$rowEmp['evaluacionR1'];
  81.                     @$dbR2=$rowEmp['evaluacionR2'];
  82.                     @$dbR3=$rowEmp['evaluacionR3'];
  83.                     echo "<tr>";
  84.                         echo "<td colspan='3'>Pregunta: ".$dbpregunta."</td>";
  85.                     echo "</tr>";
  86.                     echo "<tr>";
  87.                         echo "<td width='38'>Opcion</td>";
  88.                         echo "<td width='486'>Respuesta</td>";
  89.                         echo "<td width='69'>Correcta</td>";
  90.                     echo "</tr>";
  91.                     echo "<tr>";
  92.                         echo "<td>a</td>";
  93.                         echo "<td>".$dbR1."</td>";
  94.                         echo "<td><input name='respuesta[".$i."]' type='radio' value='1' required></td>";
  95.                     echo "</tr>";
  96.                     echo "<tr>";
  97.                         echo "<td>b</td>";
  98.                         echo "<td>".$dbR2."</td>";
  99.                         echo "<td><input name='respuesta[".$i."]' type='radio' value='2' required></td>";
  100.                     echo "</tr>";
  101.                             echo "<tr>";
  102.                                 echo "<td>c</td>";
  103.                                 echo "<td>".$dbR3."</td>";
  104.                                 echo "<td><input name='respuesta[".$i."]' type='radio' value='3' required></td>";
  105.                                 echo "<input name='destino' type='text'>";
  106.                     echo "</tr>";
  107.                     $i += 1;
  108.                 }
  109.             }
  110.         }
  111.         else
  112.         {
  113.             if ($iNumReg>0)
  114.             {
  115.                 $i = 0;  
  116.                 while ($rowEmp = mysql_fetch_assoc($result))
  117.                 {
  118.                     $dbpregunta = $rowEmp['evaluacionPregunta'];
  119.                     $dbR1=$rowEmp['evaluacionR1'];
  120.                     $dbR2=$rowEmp['evaluacionR2'];
  121.                     $dbR3=$rowEmp['evaluacionR3'];
  122.                     $dbcorrecta=$rowEmp['evaluacionRCorrecta'];
  123.                     echo "<tr>";
  124.                         echo "<td colspan='3'>Pregunta: ".$dbpregunta."</td>";
  125.                     echo "</tr>";
  126.                     echo "<tr>";
  127.                         echo "<td width='38'>Opcion</td>";
  128.                         echo "<td width='486'>Respuesta</td>";
  129.                         echo "<td width='69'>Resultado</td>";
  130.                     echo "</tr>";
  131.                     echo "<tr>";
  132.                         echo "<td>a</td>";
  133.                         if (@$respuestas[$i]=='1')
  134.                         {
  135.                             echo "<td style='background-color: beige;'>".$dbR1." (Seleccionada)</td>";
  136.                         }
  137.                         else
  138.                         {
  139.                             echo "<td>".$dbR1."</td>";
  140.                         }
  141.                         if (@$respuestas[$i]==$dbcorrecta)
  142.                         {
  143.                             echo "<td style='background-color: aquamarine;' rowspan='3'>Bien</td>";
  144.                             @$acum=$acum+1;
  145.                         }
  146.                         else
  147.                         {
  148.                             echo "<td style='background-color: salmon;'rowspan='3'>Mal</td>";
  149.                         }
  150.                         echo "</tr>";
  151.                         echo "<tr>";
  152.                             echo "<td>b</td>";
  153.                         if (@$respuestas[$i]=='2')
  154.                         {
  155.                             echo "<td style='background-color: beige;'>".$dbR2." (Seleccionada)</td>";
  156.                         }
  157.                         else
  158.                         {
  159.                             echo "<td>".$dbR2."</td>";
  160.                         }
  161.                         echo "</tr>";
  162.                         echo "<tr>";
  163.                             echo "<td>c</td>";
  164.                         if (@$respuestas[$i]=='3')
  165.                         {
  166.                             echo "<td style='background-color: beige;'>".$dbR3." (Seleccionada)</td>";
  167.                         }
  168.                         else
  169.                         {
  170.                             echo "<td>".$dbR3."</td>";
  171.                         }
  172.                         echo "</tr>";
  173.                         $i += 1;
  174.                 }
  175.             }
  176.             if (@$acum==0)
  177.             {
  178.                 $nota=0;
  179.             }
  180.             else
  181.             {
  182.                 $nota=($acum/$iNumReg)*5;
  183.             }
  184.             @$tematicaId=$_GET['tematicasId'];
  185.            
  186.             echo @$docenteId;
  187.             $matriculaId=$row_Recordset2['matriculaId'];
  188.             $estudianteId=$row_Recordset2['estudianteId'];
  189.             $sql2="select docenteId from tematicas where tematicasId='".$tematicaId."'";
  190.             $result=mysql_query($sql2);
  191.             $rowEmp = mysql_fetch_assoc($result);
  192.             $docenteId=$rowEmp['docenteId'];
  193.            
  194.             @$sql = "insert into notas values ('','$estudianteId','$tematicaId','$nota','$matriculaId','$docenteId')";
  195.             if(mysql_query ($sql))
  196.             {
  197.                 echo "Evaluacion enviada";
  198.                 echo "<br/><br/>";
  199.             }
  200.             echo "Tu nota final es de ".$nota;
  201.         }
  202.         echo "<tr><br/><br/>";
  203.         if (@$show=='0')
  204.         {
  205.             echo "<td><br><br></td><td style='text-align: center;'><input name='submit' type='submit' value='Enviar evaluacion'<a class='button white' href='#'></a></td>";
  206.         }
  207.         }
  208.        
  209.         echo "</tr>";
  210.         ?>
  211.     </form>
  212. </table>
  213.  
  214. <br/>
  215.  
  216.   <a href="curso_desarrollo.php?tematicasId=<?php echo $row_Recordset1['tematicasId']; ?>">Regresar</a>
  217. <!-- end .content -->

ahora veo que si borro lo que esta después del style y antes de scryp type, me borra el contador, yo quiero que ese se pueda seguir viendo, para que el estudiante sepa cuanto tiempo le queda.