Ver Mensaje Individual
  #6 (permalink)  
Antiguo 14/07/2015, 14:25
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.

mira ese es código completo de la pagina, ahí esta lo que tu me ayudaste anteriormente en otro post:

Código PHP:
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. </head>
  14.  
  15. <body>
  16. <form name="redirect" class="centrado">
  17. <span>Tiempo restante para finalizar</span>
  18. <br />
  19. <input type="text" size="3" name="destino" />
  20. <br />
  21. segundos
  22. <script type="text/javascript">
  23. <!--
  24. var targetURL="cursos.php" //página que se abrirá al finalizar el conteo
  25. var countdownfrom=50 //tiempo en segundos de la cuenta atrás
  26. var currentsecond=document.redirect.destino.value=countdownfrom+1
  27. function countredirect(){
  28. if (currentsecond!=1){
  29. currentsecond-=1
  30. document.redirect.destino.value=currentsecond
  31. }
  32. else{
  33. window.location=targetURL
  34.  
  35. return
  36. }
  37. setTimeout("countredirect()",1000)
  38. }
  39. countredirect()
  40. //-->
  41. </script>
  42. </form>
  43. </body>
  44.  
  45.  
  46. <?php
  47. @$tematicaId=$_GET['tematicasId'];
  48. @$usuario=$_SESSION['MM_Username'];
  49. @$sql5 = "SELECT estudianteId, tematicaId FROM notas WHERE tematicaId='".$tematicaId."' and estudianteId='".$usuario."'";
  50. @$result = mysql_query($sql5) or die(mysql_error());
  51. @$iNumReg = mysql_num_rows($result);
  52. if ($iNumReg>0)
  53. {
  54.     while ($rowEmp = mysql_fetch_assoc($result))
  55.     {
  56.         @$usuconsulta = $rowEmp['estudianteId'];
  57.         @$idconsulta = $rowEmp['tematicaId'];
  58.         if ($tematicaId==$idconsulta && $usuario==$usuconsulta)
  59.         {
  60.             echo"Ya presentaste tu evaluacion";
  61.             echo "<br/>";
  62.             $prueba=0;
  63.         }
  64.     }
  65. }
  66. else
  67. {
  68.    
  69.     if (isset($_GET['tematicasId']) && !isset($_POST['submit']))
  70.     {
  71.         @$aux=$_GET['tematicasId'];
  72.         @$var=$row_Recordset1['tematicasId'];
  73.         if ($aux==$var)
  74.         {
  75.             $sTematica=$row_Recordset1['tematicasId'];
  76.             $show='0';
  77.             @$respuestas=$_POST['respuesta'];
  78.             $prueba=1;
  79.         }
  80.         else
  81.         {
  82.             echo "Aun no se ha subido una evaluacion";
  83.             echo "<br/>";
  84.             $prueba=0;
  85.         }
  86.     }
  87.     else
  88.     {      
  89.         if (isset($_POST['submit']))
  90.         {
  91.             @$aux=$_GET['tematicasId'];
  92.             @$sTematica=$row_Recordset1['tematicasId'];
  93.             @$respuestas=$_POST['respuesta'];
  94.             @$show='1';
  95.             $prueba=1;
  96.            
  97.         }
  98.         else
  99.         {
  100.             echo "No se ha especificado una tematica de la evaluacion";
  101.             exit;
  102.         }
  103.     }
  104. }
  105. ?>
  106. <?php
  107. if (@$prueba==1)
  108. {
  109. @$sql = "SELECT * FROM evaluaciones WHERE tematicasId='".$aux."'";
  110. @$result = mysql_query($sql) or die(mysql_error());
  111. @$iNumReg = mysql_num_rows($result);
  112.  
  113. ?>
  114. <table width="615" border="1">
  115.     <form action='' method='post' name="presentar" >
  116.         <?php
  117.         if (@$show=='0')
  118.         {
  119.             if ($iNumReg>0)
  120.             {
  121.                 $i = 0;  
  122.                 while ($rowEmp = mysql_fetch_assoc($result))
  123.                 {
  124.                     @$dbpregunta = $rowEmp['evaluacionPregunta'];
  125.                     @$dbR1=$rowEmp['evaluacionR1'];
  126.                     @$dbR2=$rowEmp['evaluacionR2'];
  127.                     @$dbR3=$rowEmp['evaluacionR3'];
  128.                     echo "<tr>";
  129.                         echo "<td colspan='3'>Pregunta: ".$dbpregunta."</td>";
  130.                     echo "</tr>";
  131.                     echo "<tr>";
  132.                         echo "<td width='38'>Opcion</td>";
  133.                         echo "<td width='486'>Respuesta</td>";
  134.                         echo "<td width='69'>Correcta</td>";
  135.                     echo "</tr>";
  136.                     echo "<tr>";
  137.                         echo "<td>a</td>";
  138.                         echo "<td>".$dbR1."</td>";
  139.                         echo "<td><input name='respuesta[".$i."]' type='radio' value='1' required></td>";
  140.                     echo "</tr>";
  141.                     echo "<tr>";
  142.                         echo "<td>b</td>";
  143.                         echo "<td>".$dbR2."</td>";
  144.                         echo "<td><input name='respuesta[".$i."]' type='radio' value='2' required></td>";
  145.                     echo "</tr>";
  146.                             echo "<tr>";
  147.                                 echo "<td>c</td>";
  148.                                 echo "<td>".$dbR3."</td>";
  149.                                 echo "<td><input name='respuesta[".$i."]' type='radio' value='3' required></td>";
  150.                                
  151.                     echo "</tr>";
  152.                     $i += 1;
  153.                 }
  154.             }
  155.         }
  156.         else
  157.         {
  158.             if ($iNumReg>0)
  159.             {
  160.                 $i = 0;  
  161.                 while ($rowEmp = mysql_fetch_assoc($result))
  162.                 {
  163.                     $dbpregunta = $rowEmp['evaluacionPregunta'];
  164.                     $dbR1=$rowEmp['evaluacionR1'];
  165.                     $dbR2=$rowEmp['evaluacionR2'];
  166.                     $dbR3=$rowEmp['evaluacionR3'];
  167.                     $dbcorrecta=$rowEmp['evaluacionRCorrecta'];
  168.                     echo "<tr>";
  169.                         echo "<td colspan='3'>Pregunta: ".$dbpregunta."</td>";
  170.                     echo "</tr>";
  171.                     echo "<tr>";
  172.                         echo "<td width='38'>Opcion</td>";
  173.                         echo "<td width='486'>Respuesta</td>";
  174.                         echo "<td width='69'>Resultado</td>";
  175.                     echo "</tr>";
  176.                     echo "<tr>";
  177.                         echo "<td>a</td>";
  178.                         if (@$respuestas[$i]=='1')
  179.                         {
  180.                             echo "<td style='background-color: beige;'>".$dbR1." (Seleccionada)</td>";
  181.                         }
  182.                         else
  183.                         {
  184.                             echo "<td>".$dbR1."</td>";
  185.                         }
  186.                         if (@$respuestas[$i]==$dbcorrecta)
  187.                         {
  188.                             echo "<td style='background-color: aquamarine;' rowspan='3'>Bien</td>";
  189.                             @$acum=$acum+1;
  190.                         }
  191.                         else
  192.                         {
  193.                             echo "<td style='background-color: salmon;'rowspan='3'>Mal</td>";
  194.                         }
  195.                         echo "</tr>";
  196.                         echo "<tr>";
  197.                             echo "<td>b</td>";
  198.                         if (@$respuestas[$i]=='2')
  199.                         {
  200.                             echo "<td style='background-color: beige;'>".$dbR2." (Seleccionada)</td>";
  201.                         }
  202.                         else
  203.                         {
  204.                             echo "<td>".$dbR2."</td>";
  205.                         }
  206.                         echo "</tr>";
  207.                         echo "<tr>";
  208.                             echo "<td>c</td>";
  209.                         if (@$respuestas[$i]=='3')
  210.                         {
  211.                             echo "<td style='background-color: beige;'>".$dbR3." (Seleccionada)</td>";
  212.                         }
  213.                         else
  214.                         {
  215.                             echo "<td>".$dbR3."</td>";
  216.                         }
  217.                         echo "</tr>";
  218.                         $i += 1;
  219.                 }
  220.             }
  221.             if (@$acum==0)
  222.             {
  223.                 $nota=0;
  224.             }
  225.             else
  226.             {
  227.                 $nota=($acum/$iNumReg)*5;
  228.             }
  229.             @$tematicaId=$_GET['tematicasId'];
  230.            
  231.             echo @$docenteId;
  232.             $matriculaId=$row_Recordset2['matriculaId'];
  233.             $estudianteId=$row_Recordset2['estudianteId'];
  234.             $sql2="select docenteId from tematicas where tematicasId='".$tematicaId."'";
  235.             $result=mysql_query($sql2);
  236.             $rowEmp = mysql_fetch_assoc($result);
  237.             $docenteId=$rowEmp['docenteId'];
  238.            
  239.             @$sql = "insert into notas values ('','$estudianteId','$tematicaId','$nota','$matriculaId','$docenteId')";
  240.             if(mysql_query ($sql))
  241.             {
  242.                 echo "Evaluacion enviada";
  243.                 echo "<br/><br/>";
  244.             }
  245.             echo "Tu nota final es de ".$nota;
  246.         }
  247.         echo "<tr><br/><br/>";
  248.         if (@$show=='0')
  249.         {
  250.             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>";
  251.         }
  252.         }
  253.        
  254.         echo "</tr>";
  255.         ?>
  256.     </form>
  257. </table>
  258.  
  259. <br/>
  260.  
  261.   <a href="curso_desarrollo.php?tematicasId=<?php echo $row_Recordset1['tematicasId']; ?>">Regresar</a>