Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/01/2011, 07:47
Ryel
 
Fecha de Ingreso: octubre-2010
Ubicación: San Antonio
Mensajes: 19
Antigüedad: 13 años, 7 meses
Puntos: 0
Pregunta Bucle valores vacios

hoala a todos, tengo el siguinete problema, envio datos de un formulario con 4 cajas de textos para ingresar info en un mismo archivo:
Código PHP:
Ver original
  1. <?PHP
  2. $primero = $_POST['1'];
  3. $segundo = $_POST['2'];
  4. $tercero = $_POST['3'];
  5. $cuarto = $_POST['4'];
  6. if($primero==""||$segundo==""||$tercero==""||$cuarto==""){
  7.     echo"Sin Datos";}
  8.     else{
  9.      
  10.  
  11. $conexion= mysql_connect("localhost","root","root")or die ("no se conecto");
  12. mysql_select_db("bd",$conexion)or die ("No se conecto db");
  13.  
  14. $base=array($primero,$segundo,$tercero,$cuarto);
  15. foreach($base as $b){
  16. $sql="INSERT INTO `bd`.`pro`(`num`) values('$b')"or die("no se conecto");
  17. }
  18.  
  19. $mensaje2 = "Datos Guardados!";
  20. print "<script>alert('$mensaje2')</script>";
  21. print("<script>window.location.replace('./pro.php');</script>");
  22.     ;}
  23.  
  24. ?>

Este es el formulario, todo en el mismo archivo PHP
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>Pro</title>
  5. </head>
  6.  
  7. <table><form action="pro.php" method="post"> <tr>
  8. <th>equi1</th>
  9. <th><input name="1" type="text"></th>
  10. </tr>
  11. <tr>
  12. <th>equi2</th>
  13. <th><input name="2" type="text"></th>
  14. </tr>
  15. <tr>
  16. <th>equi3</th>
  17. <th><input name="3" type="text"></th>
  18. </tr>
  19. <tr>
  20. <th>equi4</th>
  21. <th><input name="4" type="text"></th>
  22. </tr>
  23. </tr>
  24. <tr>
  25. <th><input type="submit" name="sub"></th>
  26. <th><input type="reset" name="res"></th>
  27. </tr>
  28. </form>
  29.  
  30.  
  31. </body>
  32. </html>
a lo cual me guarda los datos en la BD, sin embargo en lo que tropiezo es como evitar guardar datos vacios , y a su vez saltar los mismos paraseguir ejecutando el bucle, si alguien me puede ayudar les estaria muy agradecido, si puede ser con ejemplos mucho mejor. Nos vemos.