Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/04/2014, 16:52
Avatar de nexus44
nexus44
 
Fecha de Ingreso: octubre-2012
Ubicación: Piura
Mensajes: 108
Antigüedad: 11 años, 6 meses
Puntos: 1
Exclamación Insertar varios registros listados

Buen día estimados amigos quisiera pedir de su ayuda esta vez , lo que trato de hacer es guardar varios "códigos" de un listado de datos después de haber hecho la búsqueda.

Una vez que hago mi búsqueda en index.php y me muestro el listado de datos mediante un div

Como inserto todos los codigos que hay en el listado en este caso : idprogramacion.

Index.php
Código PHP:
Ver original
  1. <?php
  2. $host="localhost";
  3. $user="root";
  4. $pass="";
  5. $base="colegio";
  6.  
  7. $conexion=mysql_connect($host,$user,$pass) or die ("ERROR");
  8.          mysql_select_db($base) or die ("error");        
  9.         ?>
  10. <script type="text/javascript">
  11. function newAjax(){
  12.       var xmlhttp=false;
  13.       try {
  14.          xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  15.       } catch (e) {
  16.          try {
  17.             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  18.          } catch (E) {
  19.             xmlhttp = false;
  20.          }
  21.       }
  22.       if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  23.          xmlhttp = new XMLHttpRequest();
  24.       }
  25.    return xmlhttp;
  26. }
  27.  
  28. function BusquedaDato(){
  29.  
  30.    
  31.     var idnivel   = document.busqueda.idnivel.value;
  32.     var idgrado       = document.busqueda.idgrado.value;
  33.     var idseccion       = document.busqueda.idseccion.value;   
  34.     var idanno       = document.busqueda.idanno.value;
  35.    
  36.     ajax = newAjax();
  37.     ajax.open("POST", "fechas.php", true); 
  38.     ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1');
  39.    
  40.      document.getElementById('AjaxReporteAlumnos').innerHTML="<STRONG><center>CARGANDO DATOS...</center></STRONG>";
  41.     ajax.onreadystatechange = function () {
  42.         if (ajax.readyState == 4) {
  43.             document.getElementById('AjaxReporteAlumnos').innerHTML = ajax.responseText;
  44.             div.style.display = "";
  45.         }
  46.     }
  47.     //ajax.send('Tusuario='+Tusuario+'&ciclo='+ciclo+"&carrera="+carrera);
  48.     ajax.send('idnivel='+idnivel+'&idgrado='+idgrado+'&idseccion='+idseccion+'&idanno='+idanno);
  49.     }
  50. </script>
  51. <html>
  52. <head>
  53. </head>
  54. <body>
  55. <center>
  56.  <form id="busqueda" name="busqueda" method="post" action="">  
  57.  <strong>BUSCA PROGRAMACION PARA ASIGNAR</strong>
  58.   <table width="90%" border="0" align="center"  class="down1">  
  59.   <tr>
  60.   <td>Nivel Academico:</td>
  61.   <td>
  62.     <select name="idnivel">
  63.     <?php
  64.     $sql=mysql_query("SELECT * FROM nivel_estudiantil");
  65.     while($dato=mysql_fetch_array($sql)){
  66.     ?> 
  67.     <option value="<?php echo $dato['idnivel'];?>"><?php echo $dato['descripcion'];?></option>
  68.     <?php } ?>
  69.     </select>  
  70.   </td>
  71.   <td>Grado:</td>  
  72.   <td>  
  73.     <select name="idgrado">
  74.     <?php
  75.     $sql=mysql_query("SELECT * FROM grados");
  76.     while($dato=mysql_fetch_array($sql)){
  77.     ?> 
  78.     <option value="<?php echo $dato['idgrado'];?>"><?php echo $dato['descripcion'];?></option>
  79.     <?php } ?>
  80.     </select>
  81.   </td>
  82.   </td>  
  83. <td>Seccion:</td>
  84.   <td>
  85.     <select name="idseccion">
  86.     <?php
  87.     $sql=mysql_query("SELECT * FROM seccion");
  88.     while($dato=mysql_fetch_array($sql)){
  89.     ?> 
  90.     <option value="<?php echo $dato['idseccion'];?>"><?php echo $dato['nombre'];?></option>
  91.     <?php } ?>
  92.     </select>
  93.   </td>  
  94.   <td>Año Academico:</td>
  95.   <td>
  96.     <select name="idanno">
  97.     <?php
  98.     $sql=mysql_query("SELECT * FROM annoacademico");
  99.     while($dato=mysql_fetch_array($sql)){
  100.     ?> 
  101.     <option value="<?php echo $dato['idanno'];?>"><?php echo $dato['descripcion'];?></option>
  102.     <?php } ?>
  103.     </select>
  104.   </td>
  105.    <td><input name="buscar" type="button" onClick="BusquedaDato()" class="btn btn-primary" style="cursor: pointer;"  value="BUSCAR" /></td>  
  106.   </tr>
  107.   </table>
  108.       </form>
  109.     <form name="enviar" method="post" action="">
  110.      
  111.        <div id="AjaxReporteAlumnos"><img src="img/error.gif"/> Esperando Acciones....</div>
  112.        </form>       
  113.   </center>
  114. <?php
  115.  
  116.     for($i=0;$i<=10;$i++){
  117.         echo '<br/>';
  118.     }
  119.  ?>
  120.  </body>
  121.  </html>

fechas.php
Código PHP:
Ver original
  1. <?php
  2. $host="localhost";
  3. $user="root";
  4. $pass="";
  5. $base="colegio";
  6.  
  7. $conexion=mysql_connect($host,$user,$pass) or die ("ERROR");
  8.             mysql_select_db($base) or die ("error");
  9. ?>
  10. <html>
  11. <head>
  12. <link href="css/bootstrap.css" rel="stylesheet">
  13.     <link href="css/bootstrap-responsive.css" rel="stylesheet">
  14.     <link href="css/docs.css" rel="stylesheet">
  15.     <link href="js/google-code-prettify/prettify.css" rel="stylesheet">
  16.    
  17.     <script>
  18.  
  19. function imprSelec(nombre)
  20.  
  21. {
  22.  
  23. var ficha = document.getElementById(nombre);
  24.  
  25. var ventimp = window.open(' ', 'popimpr');
  26.  
  27. ventimp.document.write( ficha.innerHTML );
  28.  
  29. ventimp.document.close();
  30.  
  31. ventimp.print( );
  32.  
  33. ventimp.close();
  34.  
  35. }
  36.  
  37. </script>
  38. </head>
  39. <body>
  40. <?php
  41.    
  42.     $idnivel    = $_POST['idnivel'];
  43.     $idgrado    = $_POST['idgrado'];
  44.     $idseccion  = $_POST['idseccion'];
  45.     $idanno     = $_POST['idanno'];
  46.    
  47.     if($idnivel==0){
  48.         echo '<img src="../imagenes/error.gif"/> ERROR SELECCIONE OPCION';
  49.     }else{
  50. ?>
  51.        
  52. <?php
  53.         $contador = 0;
  54.        
  55.  $sql="SELECT ne.idnivel , ne.descripcion , gr.idgrado ,gr.descripcion , se.idseccion , se.nombre ,an.idanno , an.descripcion ,do.doc_codigo , do.doc_nombres , do.doc_apellidos , cu.idcurso , cu.descripcion , pr.idprogramacion , pr.idnivel , pr.idgrado , pr.idseccion , pr.iddocente , pr.idcurso , pr.idanno FROM nivel_estudiantil ne , grados gr , seccion se, annoacademico an , docentes do ,cursos cu , programacion pr WHERE ne.idnivel=pr.idnivel AND gr.idgrado=pr.idgrado AND se.idseccion=pr.idseccion AND an.idanno=pr.idanno AND do.doc_codigo=pr.iddocente AND cu.idcurso=pr.idcurso AND pr.idnivel='".$idnivel."' AND pr.idgrado='".$idgrado."' AND pr.idseccion='".$idseccion."' AND pr.idanno='".$idanno."'";   
  56.         $rs  = mysql_query($sql,$conexion);
  57.         if(mysql_num_rows($rs)!=0){
  58. ?>
  59.  
  60. <table cellspacing="0" align="right">
  61.             <tr>
  62.             <td colspan=6 >
  63.             <a href="javascript:imprSelec('seleccion')" ><img src="img/print.png"></a>
  64.             </td>
  65.             </tr>
  66.             </table>
  67.             <div id="seleccion">
  68.             <table id="table" cellspacing="0" width="100%" border="1" class="table" align="center">            
  69.             <thead>
  70.             <tr class="asc" id="head">
  71.             <th align="center"><div align="center">Cod Programacion</div></th>
  72.             <th align="center"><div align="center">Curso</div></th>
  73.             <th align="center"><div align="center">Docente</div></th>
  74.             <th align="center"><div align="center">Seccion</div></th>          
  75.             </tr>
  76.             </thead>
  77.             <tbody id="tbody">
  78.  
  79.            
  80.            
  81. <?php
  82.             while($row = mysql_fetch_assoc($rs)){
  83.  
  84.                            
  85.                 echo '<td><div align="center">'.$row['idprogramacion'].'</div></td>';
  86.                 echo '<input type="text" name"idprogramacion[]" value='.$row['idprogramacion'].'>';
  87.                 echo '<td><div align="center">'.$row['descripcion'].'</div></td>';         
  88.                 echo '<td><div align="center">'.$row['doc_nombres'].' '.$row['doc_apellidos'].'</div></td>';               
  89.                 echo '<td><div align="center">'.$row['nombre'].'</div></td>';              
  90.                 echo '</tr>';      
  91.             }
  92.            
  93. ?>
  94. <form>
  95. <?php          
  96.         }
  97.         else
  98.         echo 'NO EXISTE NINGUN TIPO DE PROGRAMACION PARA LO SELECCIONADO !';
  99. ?>
  100.             </tbody>       
  101.             </table>
  102. </div>
  103. <?php
  104.     }
  105. ?>
  106. </body>
  107. </html>
__________________

"Nuestra capacidad se aleja de la Humanidad"