Ver Mensaje Individual
  #11 (permalink)  
Antiguo 01/08/2015, 12:51
Avatar de chronos682
chronos682
 
Fecha de Ingreso: febrero-2004
Ubicación: Tunja - Boyacá - Colombia
Mensajes: 627
Antigüedad: 20 años, 2 meses
Puntos: 69
Respuesta: ingresar varias imágenes a base de dtos

Aquí te paso este código para que lo estudies y lo implementes, está muy fácil de usar:

Este es el código de la página principal:

Código PHP:
Ver original
  1. <?php
  2.     $mysql = new mysqli("localhost", "root", "", "prueba");
  3. ?>
  4. <html>
  5.     <head>
  6.         <title></title>
  7.         <script>
  8.             function GetLinea(str) {
  9.                 if(window.XMLHttpRequest) {
  10.                     xmlhttp = new XMLHttpRequest();
  11.                 }
  12.                 else if(window.ActiveXObject) {
  13.                     xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  14.                 }
  15.                 xmlhttp.onreadystatechange = muestraContenido;
  16.                 xmlhttp.open("GET", "linea.php?marca=" + str, true);
  17.                 xmlhttp.send(null);
  18.                
  19.                 function muestraContenido() {
  20.                     if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  21.                         var srespuesta = xmlhttp.responseText;
  22.                         document.getElementById("divlinea").innerHTML = srespuesta;
  23.                     }
  24.                 }
  25.             }
  26.         </script>
  27.     </head>
  28.     <body>
  29.         <form name="formulario" action="" method="post">
  30.             <div style="float: left; margin-right: 15px;">
  31.                 <select name="marca" onchange="GetLinea(this.value)">
  32.                     <option value="" selected>Seleccione...</option>
  33.                     <?php
  34.                         $sql = "SELECT * FROM Marca ORDER BY Marca ASC";
  35.                         $result = $mysql->query($sql);
  36.                         while ($row = $result->fetch_assoc())
  37.                         {
  38.                             echo "<option value='{$row['ID']}'>{$row['Marca']}</option>";
  39.                         }
  40.                     ?>
  41.                 </select>
  42.             </div>
  43.             <div id="divlinea">
  44.                 <select name="marca" onchange="GetLinea(this.value)">
  45.                     <option value="" selected>Seleccione...</option>
  46.                 </select>
  47.             </div>
  48.         </form>
  49.     </body>
  50. </html>

Este es el código de la página que devuelve las líneas pertenecientes a una marca (linea.php):
Código PHP:
Ver original
  1. <?php
  2.     $mysql = new mysqli("localhost", "root", "", "prueba");
  3.     if (isset($_GET['marca']))
  4.     {
  5.         $marca = $_GET['marca'];
  6.         $sql = "SELECT * FROM linea WHERE Marca = '{$marca}' ORDER BY Linea ASC";
  7.         $result = $mysql->query($sql);
  8.         echo "<select name='linea'>";
  9.         echo "<option value='' selected>Seleccione...</option>";
  10.         while ($row = $result->fetch_assoc())
  11.         {
  12.             echo "<option value='{$row['ID']}'>{$row['Linea']}</option>";
  13.         }
  14.         echo "</select>";
  15.     }
  16. ?>

Ajústalos a tus necesidades.
__________________
Si te gustó la respuesta dale +1

HERNÁN G. SIABATO M.
[email protected]