Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/09/2013, 19:33
Avatar de AnGuisi
AnGuisi
 
Fecha de Ingreso: julio-2013
Ubicación: San Felipe - Yaracuy
Mensajes: 122
Antigüedad: 10 años, 9 meses
Puntos: 2
Update Mysql en PHP

Tengo el siguiente formulario y el script que procesa tal formulario.

Formulario:
Código HTML:
Ver original
  1. <table width="100%">
  2.  
  3. <form id="busq" name="busq" action="controlador_modificar_hardware.php" method="POST">
  4.  
  5.     <tr>
  6.         <td>HARDWARE</td>
  7.         <td>MARCA</td>
  8.         <td>MODELO</td>
  9.         <td>TIPO</td>
  10.          <td>SERIAL</td>
  11.         <td>OBSERVACIONES</td>
  12.        
  13.       </tr>
  14.  
  15.       <?
  16.      
  17. foreach ($row as $datos) {
  18.       ?>
  19.        
  20.  
  21.       <tr>
  22.  
  23.  
  24.      
  25.    
  26.        
  27.      <td><input type="text" name="tipo[]" value="<? echo $datos['tipo_h']; ?>" disabled="disabled" /> </td>
  28. <td><input type="text" class="form" name="marca[]" value="<? echo $datos['marca']; ?>" disabled="disabled" /></td>
  29.        
  30.         <td><input type="text" class="form" name="modelo[]" value="<? echo $datos['modelo']; ?>" disabled="disabled" /></td>
  31.         <td><input type="text" class="form" name="tipo_nombre[]" value="<? echo $datos['tipo_nombre']; ?>" disabled="disabled" /></td>
  32.         <td><input type="text" class="form" name="serial[]" value="<? echo $datos['serial']; ?>" disabled="disabled" /></td>
  33.         <td><input type="text" class="form" name="observaciones_h[]" value="<? echo $datos['observaciones_h']; ?>" disabled="disabled" /></td>
  34.         <input type="text" class="form" name="id_hardware[]" value="<? echo $datos['id_hardware']; ?>" disabled="disabled" />              
  35.        
  36.    </tr>
  37.    
  38.      
  39.  
  40.       <?
  41.      
  42.        }
  43.        ?>
  44.  
  45.    
  46.        <input type="text" id="codigo" class="form" name="codigo" value="<? echo $datos['codigo']; ?>" disabled="disabled" />
  47.  
  48.  </form>  
  49.     </table>
  50.   </div>
  51.  </br>
  52.      <div align="center"><button id="activar" type="button" style="display:block;" onclick="mostrar_ocultar3('activar','modificar')">Modificar Registro</button></div>
  53.      </br>
  54.      
  55.      
  56.      <div align="center"><input type="submit" id="modificar" name="modificar" style="display:none;" value="Incluir Modificacion" /></div>
  57.      
  58.      </br></br>

Function:
Código PHP:
Ver original
  1. public function editar($datos = array()) {
  2.          
  3.          
  4.           while (true) {
  5.          
  6.           $tipo_nombre = current($tipo_nombre);
  7.           $serial = current($serial);
  8.           $observaciones_h = current($observaciones_h);
  9.          
  10.  
  11.                
  12.           if ($codigo != '') {
  13.               $query = "UPDATE `soptecvnzla`.`caracteristicas_hardware` SET serial = '$serial', observaciones_h = '$observaciones_h', tipo_nombre = '$tipo_nombre' WHERE codigo = '$codigo' AND id_hardware = '$id_hardware'";
  14.              
  15.      
  16.           $tipo_nombre = current($tipo_nombre);
  17.           $serial = current($serial);
  18.           $observaciones_h = current($observaciones_h);
  19.           $id_hardware = current($id_hardware);
  20.              
  21.         if($tipo_nombre === false && $serial === false && $observaciones_h === false && $id_hardware === false)
  22.         break;
  23.              
  24.               $mysqli = $this->abrir_conexion();
  25.               $result = $mysqli->query($query);
  26.           }
  27.            
  28.               if (!$result) {
  29.                 echo "error".$mysqli->error;
  30.             }
  31.             return $result;
  32.           }

El problema esta en que no me modifica, me causa error. Como pueden observar intento hacer un ciclo de UPDATE mientras reciba los valores de los arrays en el formulario.

Creo que el error esta tambien en la funcion extract puesto que esta recibe otros arrays. Agradezco de antemano cualquier ayuda.