Ver Mensaje Individual
  #23 (permalink)  
Antiguo 22/01/2013, 04:38
Avatar de satjaen
satjaen
 
Fecha de Ingreso: septiembre-2012
Ubicación: Jaén (Andalucía)
Mensajes: 893
Antigüedad: 11 años, 8 meses
Puntos: 10
Respuesta: Consulta de Campos en tablas.

Lo estoy haciendo así, pero no me inserta nada:

Código HTML:
Ver original
  1. <div id="TabbedPanels2" class="TabbedPanels">
  2.             <ul class="TabbedPanelsTabGroup">
  3.               <li class="TabbedPanelsTab" tabindex="0">Dirección</li>
  4.               <li class="TabbedPanelsTab" tabindex="0">Dirección 2</li>
  5.               <li class="TabbedPanelsTab" tabindex="0">Dirección 3</li>
  6.             </ul>
  7.             <div class="TabbedPanelsContentGroup">
  8.               <div class="TabbedPanelsContent">
  9.               <table width="100%">
  10.                   <tr>
  11.                     <th scope="col">Calle</th>
  12.                     <input name="NUM_DIR[]" type="hidden" size="" value="1" />
  13.                     <th scope="col"><input name="calle[]" type="text" size="30"value="" /></th>
  14.                     <th scope="col"></th>
  15.                     <th scope="col"><input name="numero[]" type="text" size="1"value="" />
  16.                     EDF
  17.                     <input name="edificio[]" type="text" size="1"value="" />
  18.                     PTA
  19.                     <input name="puerta[]" type="text" size="1"value="" />
  20.                     PISO
  21.                     <input name="piso[]" type="text" size="1"value="" />
  22.                     LTA
  23.                     <input name="letra[]" type="text" size="1"value="" /></th>
  24.                 </tr>
  25.                      <tr>
  26.                     <th scope="col">Localidad</th>
  27.                     <th scope="col"><input name="poblacion[]" type="text" size="30" value="" /></th>
  28.                     <th scope="col">Provincia</th>
  29.                     <th scope="col"><input name="provincia[]" type="text" size="30" value="" /></th>
  30.                   </tr>
  31.                   <tr>
  32.                   <th scope="col">Email</th>
  33.                     <th scope="col"><input name="email[]" type="text" size="30" value=""/></th>
  34.                 </tr>
  35.               </table>
  36.               </div>
  37.               <div class="TabbedPanelsContent">
  38.                <table width="100%">
  39.                   <tr>
  40.                     <th scope="col">Calle</th>
  41.                     <input name="NUM_DIR[]" type="hidden" size="" value="2" />
  42.                     <th scope="col"><input name="calle[]" type="text" size="30"value="" /></th>
  43.                     <th scope="col"></th>
  44.                     <th scope="col"><input name="numero[]" type="text" size="1"value="" />
  45.                     EDF
  46.                     <input name="edificio[]" type="text" size="1"value="" />
  47.                     PTA
  48.                     <input name="puerta[]" type="text" size="1"value="" />
  49.                     PISO
  50.                     <input name="piso[]" type="text" size="1"value="" />
  51.                     LTA
  52.                     <input name="letra[]" type="text" size="1"value="" /></th>
  53.                 </tr>
  54.                      <tr>
  55.                     <th scope="col">Localidad</th>
  56.                     <th scope="col"><input name="poblacion[]" type="text" size="30" value="" /></th>
  57.                     <th scope="col">Provincia</th>
  58.                     <th scope="col"><input name="provincia[]" type="text" size="30" value="" /></th>
  59.                   </tr>
  60.                   <tr>
  61.                   <th scope="col">Email</th>
  62.                     <th scope="col"><input name="email[]" type="text" size="30" value=""/></th>
  63.                 </tr>
  64.               </table>
  65.               </div>
  66.               <div class="TabbedPanelsContent">
  67.                <table width="100%">
  68.                   <tr>
  69.                     <th scope="col">Calle</th>
  70.                     <input name="NUM_DIR[]" type="hidden" size="" value="3" />
  71.                     <th scope="col"><input name="calle[]" type="text" size="30"value="" /></th>
  72.                     <th scope="col"></th>
  73.                     <th scope="col"><input name="numero[]" type="text" size="1"value="" />
  74.                     EDF
  75.                     <input name="edificio[]" type="text" size="1"value="" />
  76.                     PTA
  77.                     <input name="puerta[]" type="text" size="1"value="" />
  78.                     PISO
  79.                     <input name="piso[]" type="text" size="1"value="" />
  80.                     LTA
  81.                     <input name="letra[]" type="text" size="1"value="" /></th>
  82.                 </tr>
  83.                      <tr>
  84.                     <th scope="col">Localidad</th>
  85.                     <th scope="col"><input name="poblacion[]" type="text" size="30" value="" /></th>
  86.                     <th scope="col">Provincia</th>
  87.                     <th scope="col"><input name="provincia[]" type="text" size="30" value="" /></th>
  88.                   </tr>
  89.                   <tr>
  90.                   <th scope="col">Email</th>
  91.                     <th scope="col"><input name="email[]" type="text" size="30" value=""/></th>
  92.                 </tr>
  93.               </table>
  94.               </div>

Código PHP:

<?php require_once('Connections/conexion.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}
$id_aviso=$_POST['id_aviso'];
$poblacion $_POST['poblacion'];
$provincia$_POST['provincia'];
$calle $_POST['calle'];
$numero $_POST['numero'];
$edificio$_POST['edificio'];
$puerta $_POST['puerta'];
$piso $_POST['piso'];
$letra$_POST['letra'];
$email $_POST['email'];
$NUM_DIR $_POST['NUM_DIR'];

$total count($poblacion);
for (
$i 0$i $total$i++) {
        
$poblacion $poblacion[$i];
        
$provincia $provincia[$i];
        
$calle $calle[$i];
        
$numero $numero[$i];
        
$edificio $edificio[$i];
        
$puerta $puerta[$i];
        
$piso $piso[$i];
        
$letra $letra[$i];
        
$email $email[$i];
        
$NUM_DIR $NUM_DIR[$i];
 
       echo 
"INSERT INTO dir_usuarios VALUES (id_aviso,'$poblacion', '$provincia', '$calle','$numero', '$edificio', '$puerta','$piso', '$letra', '$email', '$NUM_DIR')";
}

mysql_select_db($database_conexion$conexion);
$query_usuarios "SELECT *
FROM usuarios WHERE id_aviso='$id_aviso'"
;
$usuarios mysql_query($query_usuarios$conexion) or die(mysql_error());
$row_usuarios mysql_fetch_assoc($usuarios);
$totalRows_usuarios mysql_num_rows($usuarios);


mysql_select_db($database_conexion$conexion);
$query_Recordset2 "SELECT * FROM dir_usuarios where id_aviso='$id_aviso' AND NUM_DIR='1'";
$Recordset2 mysql_query($query_Recordset2$conexion) or die(mysql_error());
$row_Recordset2 mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 mysql_num_rows($Recordset2);


?>