Ver Mensaje Individual
  #6 (permalink)  
Antiguo 22/01/2015, 09:42
mbrisenog
 
Fecha de Ingreso: diciembre-2014
Mensajes: 72
Antigüedad: 9 años, 5 meses
Puntos: 0
Respuesta: guardar valores de input text en arreglos

Este es todo el codigo de mi archivo cotizador.php

Código PHP:
Ver original
  1. <?php
  2.  
  3. mysql_connect('localhost','root','')or die ('Ha fallado la conexión: '.mysql_error());
  4. mysql_select_db('basecotizador')or die ('Error al seleccionar la Base de Datos: '.mysql_error());
  5. $user=$_SESSION['usuario'];
  6.  
  7.  
  8. date_default_timezone_set('America/Mexico_City');
  9. $diaactual=date("d");
  10. $mesactual=date("m");
  11. $anioactual=date("Y");
  12. $nombredia=date("D");
  13. setlocale(LC_TIME, 'es_MX.UTF-8');
  14. $hoy=strftime("%Y-%m-%d");
  15.  
  16. $cantidad=$_POST["cantidad"];
  17. $descripcion=$_POST["descripcion"];
  18. $precio=$_POST["precio"];
  19.  
  20. $sql = 'INSERT INTO temporal (cantidad, descripcion, precio) VALUES (\''.$cantidad.'\',\''.$descripcion.'\',\''.$precio.'\')';
  21.  
  22.  
  23. $tempo = mysql_query("SELECT * FROM temporal ");
  24.  
  25. $arraycantidad = array();
  26.  
  27. ?>
  28.  
  29.  
  30.  
  31.  
  32. <html>
  33. <head>
  34.     <meta charset="UTF-8">
  35.     <meta name="author" content="Mauricio Briseño de la Garza"/>
  36.     <title>ABANZA | PORTAL ADMINISTRATIVO</title>
  37.     <link rel="stylesheet" type="text/css" href="estilos.css">
  38.     <link rel="stylesheet" type="text/css" href="fonts.css">
  39. </head>
  40. <body>
  41.         <div align="center">
  42.         <nav>
  43.             <ul id="menu">
  44.                 <li><a href="">Inicio</a></li>
  45.                 <li><a href="">Editar Pagina</a></li>
  46.                 <li><a href="">Mensajes</a></li>
  47.                 <li><a href="generar cotizaciones.php">Generar Cotizaciones</a></li>
  48.                 <li><a href="">Generar Emails</a></li>
  49.                 <li><a href="">Ajustes de Usuarios</a></li>
  50.             </ul>
  51.         </nav>
  52.         </div>
  53.        
  54.        
  55.  
  56.                 <div align="center">
  57.                
  58.                 <p align="center" class="tit"><stronger>COTIZADOR</stronger></p>
  59.  
  60.                 <form method="post" action="cotizador.php">
  61.                                
  62.                 <table class="datos">
  63.            
  64.                 <tr><td>Fecha:</td><td><input type="date" class="fecha" name="fecha" value="<? echo $hoy; ?>" ></td></tr>
  65.  
  66.                 </table>
  67.  
  68.                 <table class="datos2">
  69.                 <tr><td>CANTIDAD</td><td>DESCRIPCION</td><td>PRECIO</td></tr>
  70.                 <? while($row=mysql_fetch_array($tempo)){ ?>
  71.                 <tr>
  72.                 <td><input type="text" name="arraycantidad[]" class="cantidad" value=<? echo $row[1]; ?> ></td>
  73.                 <td><input type="text" name="arraydescripcion[]" class="descripcion" value=<? echo $row[2]; ?> ></td>
  74.                 <td><input type="text" name="arrayprecio[]" class="precio" value=<? echo $row[3]; ?> /></td>
  75.                 <td><br></td>
  76.                 </tr>
  77.                 <? }
  78.  
  79.                 ?>
  80.                
  81.                 <tr>
  82.                     <td><input type="text" name="cantidad" class="cantidad" /></td>
  83.                     <td><input type="text" name="descripcion" class="descripcion" /></td>
  84.                     <td><input type="text" name="precio" class="precio" /></td>
  85.                     <td><input type="submit" name="mas" value="+" class="mas"></td>
  86.                 </tr>
  87.                    
  88.         </table>
  89. </form>
  90.      <?  
  91.  
  92.        if(empty($arraycantidad))
  93. {echo"<p>Vacio</p>";}
  94. else
  95. {
  96. foreach ($arraycantidad as $val)
  97.   {
  98.     echo $val;
  99.   }
  100.  
  101.  
  102. }?>
  103.  
  104. </div>
  105.  
  106. </body>
  107. </html>