Foros del Web » Programando para Internet » PHP »

enviar datos de una consulta a una base de datos

Estas en el tema de enviar datos de una consulta a una base de datos en el foro de PHP en Foros del Web. buenas tengo un problema y es que necesito insertar unos datos ah mi base de datos Rparticipantes pero primero los consulto y los busco con ...
  #1 (permalink)  
Antiguo 23/09/2015, 20:19
 
Fecha de Ingreso: septiembre-2015
Mensajes: 7
Antigüedad: 8 años, 7 meses
Puntos: 0
enviar datos de una consulta a una base de datos

buenas tengo un problema y es que necesito insertar unos datos ah mi base de datos Rparticipantes pero primero los consulto y los busco con un buscador en tiempo real pero quiero que me envie todos los datos de una tabla mediante un CHECK BOX O RADIO vi algunos tutoriales de php he intente hacerlo pero me manda un error Table "#'cursos.naf' doesn't exist "# podrian ayudarme por favor


AQUI ESTA EL RADIO buscarcurso.php
Código PHP:
Ver original
  1. <?php
  2. include('conexion.php');
  3.  
  4. $dato = $_POST['dato'];
  5.  
  6. //EJECUTAMOS LA CONSULTA DE BUSQUEDA
  7.  
  8. $registro = mysql_query("SELECT * FROM rformacion WHERE naf LIKE '%$dato%' ORDER BY naf ASC");
  9.  
  10. //CREAMOS NUESTRA VISTA Y LA DEVOLVEMOS AL AJAX
  11. echo '<table class="table table-striped table-condensed table-hover">
  12.  
  13. <form action="validaremos.php" method="post">
  14.  
  15.             <tr>
  16.                 <th width="400">Cursos</th>
  17.                 <th width="200">Fecha inicio</th>
  18.                  <th width="400">Fecha Fin</th>
  19.                  <th width="400">Region</th>
  20.                  <th width="400">Gerencia</th>
  21.                  <th width="400">Departamento</th>
  22.                  <th width="400">Division</th>
  23.                  <th width="400">Ceco</th>
  24.                 <th width="50">Selecione</th>
  25.            </tr>';
  26.            
  27. if(mysql_num_rows($registro)>0){
  28.     while($registro2 = mysql_fetch_array($registro)){
  29.         echo '<tr>
  30.                 <td>'.$registro2['naf'].'</td>
  31.                 <td>'.fechainicio($registro2['fechai']).'</td>
  32.                 <td>'.fechafin($registro2['fechaf']).'</td>
  33.                 <td>'.$registro2['region'].'</td>
  34.                 <td>'.$registro2['gerencia'].'</td>
  35.                 <td>'.$registro2['depatamento'].'</td>
  36.                 <td>'.$registro2['division'].'</td>
  37.                 <td>'.$registro2['ceco'].'</td>
  38.                
  39.        
  40.                 <td><input name="very[]" id="very[]" type="radio" value="<td>'.$registro2['naf'].'</td>" /></td>
  41.  
  42.  
  43.  
  44.                 </tr>';
  45.     }
  46. }else{
  47.     echo '<tr>
  48.                 <td colspan="6">No se encontraron resultados</td>
  49.             </tr>';
  50. }
  51. echo '</table>';
  52. ?>
  53.  
  54.  <input type="submit" name="enviar" id="enviar" value="Enviar"  />
  55.  
  56.  </form>
  57.   <?php
  58. mysql_free_result($Recordset1);
  59. ?>









aqui vali la informacion que envio por el check box validaremos.php
Código PHP:
Ver original
  1. <?php require_once('../../Connections/cursos.php');  
  2. mysql_select_db($database_cursos, $cursos);
  3. ?>
  4.  
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
  6. <title>Documento sin título</title>  
  7.  
  8. <?php  
  9. // consulto la el ultimo numero de orden emitida, en este caso el encabezado, y lo ordeno de forma desendente
  10. $query_ulencado = "SELECT nafr FROM rparticipantes ORDER BY IDORDEN DESC";
  11. $ulencado = mysql_query($query_ulencado, $cursos) or die(mysql_error());
  12. $row_ulencado = mysql_fetch_assoc($ulencado);
  13.  
  14. $row_ulencado = mysql_fetch_assoc($ulencado);
  15. //verificamos que se marcara al menos 1 checkbox  
  16. echo '<pre>';
  17. echo '<p>Se guardaron los siguientes registros:</p>';
  18. echo '<p>__________________________________________________</p>';
  19. if (isset($_POST['very'])) {  
  20.      foreach($_POST['very'] as $id) {  
  21.                  $sql1="SELECT * FROM rformacion where naf = '$id'";
  22.                 $rs1=mysql_query($sql1);
  23.                 $fill = mysql_fetch_array($rs1);
  24.                 mysql_query("INSERT INTO rparticipantes (naf,fechai, fechaf, region, gerencia, depatamento,division,ceco) VALUES ('".$row_ulencado['nafr']."','".$fill['fechain']."','".$fill['fechafi']."','".$fill['region']."','".$fill['gerencia']."','".$fill['depatamento']."','".$fill['division']."','".$fill['ceco']."' )") or die(mysql_error());
  25.                echo '<p>curso: '.$id.'</p>';
  26.                echo '<p>Fecha Inicio: '.$fill['fechain'].'</p>';
  27.                echo '<p>Fecha final: '.$fill['fechafi'].'</p>';
  28.                echo '<p>region: '.$fill['region'].'</p>';
  29.                   echo '<p>Gerencia: '.$fill['gerencia'].'</p>';
  30.                      echo '<p>Departamento: '.$fill['depatamento'].'</p>';
  31.                      
  32.                    echo '<p>Division: '.$fill['division'].'</p>';
  33.                       echo '<p>Ceco: '.$fill['ceco'].'</p>';
  34.                echo '<p>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</p>';
  35.      }  
  36. }?>

Etiquetas: fecha, html, mysql, registro, select, sql, tabla
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:22.