Ver Mensaje Individual
  #9 (permalink)  
Antiguo 14/05/2012, 13:37
Avatar de mexbale
mexbale
 
Fecha de Ingreso: septiembre-2010
Ubicación: Iztapalapa
Mensajes: 143
Antigüedad: 4 años
Puntos: 1
Respuesta: Varios registros pero con condición

Ok espero que asi si me explique bien tengo todo este codigo:


Código PHP:
Ver original
  1. <?PHP  //primera Tabla
  2. if(isset($_POST["Guardar"]))
  3. {
  4.  
  5. $P01_01 = $_POST['P01_01'] = trim($_POST['P01_01']);
  6. $P01_02 = $_POST['P01_02'] = trim($_POST['P01_02']);
  7. $P01_03 = $_POST['P01_03'] = trim($_POST['P01_03']);
  8. $P01_04 = $_POST['P01_04'] = trim($_POST['P01_04']);
  9. $P01_05 = $_POST['P01_05'] = trim($_POST['P01_05']);
  10. $P01_06 = $_POST['P01_06'] = trim($_POST['P01_06']);
  11. $P01_07 = $_POST['P01_07'] = trim($_POST['P01_07']);
  12. $P01_08 = $_POST['P01_08'] = trim($_POST['P01_08']);
  13. $P01_09 = $_POST['P01_09'] = trim($_POST['P01_09']);
  14. $P01_10 = $_POST['P01_10'] = trim($_POST['P01_10']);
  15. $P02_01 = trim($_POST['P02_01']);
  16. if (empty($P02_01)){$P02_01='NULL';}
  17. $P02_02 = trim($_POST['P02_02']);
  18. if (empty($P02_02)){$P02_02='NULL';}
  19. $P02_03 = trim($_POST['P02_03']);
  20. if (empty($P02_03)){$P02_03='NULL';}
  21. $P02_04 = trim($_POST['P02_04']);
  22. if (empty($P02_04)){$P02_04='NULL';}
  23. $P02_05 = trim($_POST['P02_05']);
  24. if (empty($P02_05)){$P02_05='NULL';}
  25. $P02_06 = trim($_POST['P02_06']);
  26. if (empty($P02_06)){$P02_06='NULL';}
  27. $P02_07 = trim($_POST['P02_07']);
  28. if (empty($P02_07)){$P02_07='NULL';}
  29. $P02_08 = trim($_POST['P02_08']);
  30. if (empty($P02_08)){$P02_08='NULL';}
  31. $P02_09 = trim($_POST['P02_09']);
  32. if (empty($P02_09)){$P02_09='NULL';}
  33. $P02_10 = trim($_POST['P02_10']);
  34. if (empty($P02_10)){$P02_10='NULL';}
  35. $P03_01 = trim($_POST['P03_01']);
  36. if (empty($P03_01)){$P03_01='NULL';}
  37. $P03_02 = trim($_POST['P03_02']);
  38. if (empty($P03_02)){$P03_02='NULL';}
  39. $P03_03 = trim($_POST['P03_03']);
  40. if (empty($P03_03)){$P03_03='NULL';}
  41. $P03_04 = trim($_POST['P03_04']);
  42. if (empty($P03_04)){$P03_04='NULL';}
  43. $P03_05 = trim($_POST['P03_05']);
  44. if (empty($P03_05)){$P03_05='NULL';}
  45. $P03_06 = trim($_POST['P03_06']);
  46. if (empty($P03_06)){$P03_06='NULL';}
  47. $P03_07 = trim($_POST['P03_07']);
  48. if (empty($P03_07)){$P03_07='NULL';}
  49. $P03_08 = trim($_POST['P03_08']);
  50. if (empty($P03_08)){$P03_08='NULL';}
  51. $P03_09 = trim($_POST['P03_09']);
  52. if (empty($P03_09)){$P03_09='NULL';}
  53. $P03_10 = trim($_POST['P03_10']);
  54. if (empty($P03_10)){$P03_10='NULL';}
  55.  
  56. // Paso 1: Recibimos el formulario:
  57. $FOLIO = $_POST['FOLIO'] = trim($_POST['FOLIO']);
  58. $link = mysql_connect('localhost', 'root', '********');
  59. if (!$link) {
  60.   die('No pudo conectarse: ' . mysql_error());
  61. }
  62. mysql_select_db('REPUBLICA');
  63.  
  64. $qry="INSERT INTO DATO1 (ID, P01_01, P02_01, P03_01, FECHA)
  65. VALUES
  66. ('01', '$P01_01', $P02_01, $P03_01, NOW()),
  67. ('02', '$P01_02', $P02_02, $P03_02, NOW()),
  68. ('03', '$P01_03', $P02_03, $P03_03, NOW()),
  69. ('04', '$P01_04', $P02_04, $P03_04, NOW()),
  70. ('05', '$P01_05', $P02_05, $P03_05, NOW()),
  71. ('06', '$P01_06', $P02_06, $P03_06, NOW()),
  72. ('07', '$P01_07', $P02_07, $P03_07, NOW()),
  73. ('08', '$P01_08', $P02_08, $P03_08, NOW()),
  74. ('09', '$P01_09', $P02_09, $P03_09, NOW()),
  75. ('10', '$P01_10', $P02_10, $P03_10, NOW());";
  76.  
  77. mysql_query ($qry);
  78.  
  79. }
?>
Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>PRUEBA</title>
  5. </head>
  6.  
  7. <form name="formulario" id="formulario" action="<?=$_SERVER['PHP_SELF']?>" method="post" >
  8.   <tr>
  9.     <td>RENGLONES PARA CAPTURAR</td>
  10.     <td><input type="text" name="NC" id="NC" size="2" maxlength="2" /></td>
  11.   </tr>
  12.   <tr>
  13.     <td><div align="center">ID</div></td>
  14.     <td><div align="center">NOMBRE</div></td>
  15.     <td><div align="center">SEXO</div></td>
  16.     <td><div align="center">EDAD</div></td>
  17.   </tr>
  18.   <tr>
  19.     <td><div align="center">01</div></td>
  20.     <td><div align="center">
  21.       <input type="text" name="P01_01" id="P01_01" />
  22.     </div></td>
  23.     <td><div align="center">
  24.       <input type="text" name="P02_01" id="P02_01" size="1" maxlength="1" />
  25.     </div></td>
  26.     <td><div align="center">
  27.       <input type="text" name="P03_01" id="P03_01" size="3" maxlength="3" />
  28.     </div></td>
  29.   </tr>
  30.   <tr>
  31.     <td><div align="center">02</div></td>
  32.     <td><div align="center">
  33.       <input type="text" name="P01_02" id="P01_02" />
  34.     </div></td>
  35.     <td><div align="center">
  36.       <input type="text" name="P02_02" id="P02_02" size="1" maxlength="1" />
  37.     </div></td>
  38.     <td><div align="center">
  39.       <input type="text" name="P03_02" id="P03_02" size="3" maxlength="3" />
  40.     </div></td>
  41.   </tr>
  42.   <tr>
  43.     <td><div align="center">03</div></td>
  44.     <td><div align="center">
  45.       <input type="text" name="P01_03" id="P01_03" />
  46.     </div></td>
  47.     <td><div align="center">
  48.       <input type="text" name="P02_03" id="P02_03" size="1" maxlength="1" />
  49.     </div></td>
  50.     <td><div align="center">
  51.       <input type="text" name="P03_03" id="P03_03" size="3" maxlength="3" />
  52.     </div></td>
  53.   </tr>
  54.   <tr>
  55.     <td><div align="center">04</div></td>
  56.     <td><div align="center">
  57.       <input type="text" name="P01_04" id="P01_04" />
  58.     </div></td>
  59.     <td><div align="center">
  60.       <input type="text" name="P02_04" id="P02_04" size="1" maxlength="1" />
  61.     </div></td>
  62.     <td><div align="center">
  63.       <input type="text" name="P03_04" id="P03_04" size="3" maxlength="3" />
  64.     </div></td>
  65.   </tr>
  66.   <tr>
  67.     <td><div align="center">05</div></td>
  68.     <td><div align="center">
  69.       <input type="text" name="P01_05" id="P01_05" />
  70.     </div></td>
  71.     <td><div align="center">
  72.       <input type="text" name="P02_05" id="P02_05" size="1" maxlength="1" />
  73.     </div></td>
  74.     <td><div align="center">
  75.       <input type="text" name="P03_05" id="P03_05" size="3" maxlength="3" />
  76.     </div></td>
  77.   </tr>
  78.   <tr>
  79.     <td><div align="center">06</div></td>
  80.     <td><div align="center">
  81.       <input type="text" name="P01_06" id="P01_06" />
  82.     </div></td>
  83.     <td><div align="center">
  84.       <input type="text" name="P02_06" id="P02_06" size="1" maxlength="1" />
  85.     </div></td>
  86.     <td><div align="center">
  87.       <input type="text" name="P03_06" id="P03_06" size="3" maxlength="3" />
  88.     </div></td>
  89.   </tr>
  90.   <tr>
  91.     <td><div align="center">07</div></td>
  92.     <td><div align="center">
  93.       <input type="text" name="P01_07" id="P01_07" />
  94.     </div></td>
  95.     <td><div align="center">
  96.       <input type="text" name="P02_07" id="P02_07" size="1" maxlength="1" />
  97.     </div></td>
  98.     <td><div align="center">
  99.       <input type="text" name="P03_07" id="P03_07" size="3" maxlength="3" />
  100.     </div></td>
  101.   </tr>
  102.   <tr>
  103.     <td><div align="center">08</div></td>
  104.     <td><div align="center">
  105.       <input type="text" name="P01_08" id="P01_08" />
  106.     </div></td>
  107.     <td><div align="center">
  108.       <input type="text" name="P02_08" id="P02_08" size="1" maxlength="1" />
  109.     </div></td>
  110.     <td><div align="center">
  111.       <input type="text" name="P03_08" id="P03_08" size="3" maxlength="3" />
  112.     </div></td>
  113.   </tr>
  114.   <tr>
  115.     <td><div align="center">09</div></td>
  116.     <td><div align="center">
  117.       <input type="text" name="P01_09" id="P01_09" />
  118.     </div></td>
  119.     <td><div align="center">
  120.       <input type="text" name="P02_09" id="P02_09" size="1" maxlength="1" />
  121.     </div></td>
  122.     <td><div align="center">
  123.       <input type="text" name="P03_09" id="P03_09" size="3" maxlength="3" />
  124.     </div></td>
  125.   </tr>
  126.   <tr>
  127.     <td><div align="center">10</div></td>
  128.     <td><div align="center">
  129.       <input type="text" name="P01_10" id="P01_10" />
  130.     </div></td>
  131.     <td><div align="center">
  132.       <input type="text" name="P02_10" id="P02_10" size="1" maxlength="1" />
  133.     </div></td>
  134.     <td><div align="center">
  135.       <input type="text" name="P03_10" id="P03_10" size="3" maxlength="3" />
  136.     </div></td>
  137.   </tr>
  138.   <tr>
  139.     <td colspan="4"><div align="center">
  140.       <input type="submit" name="Guardar" value="Guardar" />
  141.     </div></td>
  142.     </tr>
  143. </form>
  144. </body>
  145. </html>

Lo que quiero hacer es que con el campo de tengo llamado "NC" insertar el numero que tecleen ahí

por ejemplo: si teclean 03 en ese campo que nada mas inserte 3 renglones en la base de datos de los diez que tengo por defecto.

de antemano les doy las gracias y espero que con esto quede claro lo que quiero hacer (soy novato quisiera que me lo detallaran el procedimiento)

buena tarde tengan