Cita:
Iniciado por GatorV
Pues el problema es que estas sobreescribiendo tus variables, fíjate:
Ahí ya perdiste la variable original, tienes que usar otro nombre de variable diferente, en el ejemplo que te di estoy usando dos variables, $nombres es un arreglo con los nombres, y $nombre es la variable local que se asigna dentro del ciclo.
Saludos.
Lo he puesto así, pero no consigo que me haga el INSERT.
Código PHP:
Ver original<?php require_once('Connections/conexion.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
}
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'];
$localidad = $_POST['localidad'];
$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($localidad); for ($i = 0; $i < $total; $i++) {
$local = $localidad[$i];
$prov = $provincia[$i];
$call = $calle[$i];
$nume = $numero[$i];
$edif = $edificio[$i];
$puer = $puerta[$i];
$pis = $piso[$i];
$letr = $letra[$i];
$emai = $email[$i];
echo "INSERT INTO dir_usuarios VALUES ('$local', '$prov', '$call', '$nume', '$edif', '$puer', '$pis', '$letr', '$emai',NUM_DIR,id_aviso)";
}
$query_usuarios = "SELECT *
FROM usuarios WHERE id_aviso='$id_aviso'";
$query_Recordset2 = "SELECT * FROM dir_usuarios where id_aviso='$id_aviso' AND NUM_DIR='1'";
?>