I have a question about ciclo for
, is that I have a form where I send and I receive the following variables:
case 'updatePD': //ACTUALIZACION DEL COLABORADOR
if(!empty($_POST['consecutivo'])){
$n=count($_POST['consecutivo']);
$iddatospersonales=$_SESSION['iddatospersonales'];
$cedula=$_SESSION['numdocumcolaboradorview'];
for ($i=0; $i<$n; $i++) {
$rutaarchivo="../../assets/files/upload/archivo/";
if (empty($_POST['idprocesodisciplinario'][$i])) {
$_POST['idprocesodisciplinario'][$i]=0;
}
if (empty($_POST['causa'][$i])) {
$_POST['causa'][$i]=-1;
}
echo "CAUSA: ". $_POST['causa'][$i]." CONSECUTIVO: ".$_POST['consecutivo'][$i];
echo "<br>";
$query=$obj->post_ejecutar("SELECT * FROM procesodisciplinario WHERE
idprocesodisciplinario=".$_POST['idprocesodisciplinario'][$i]."
ORDER BY idprocesodisciplinario");
$opcion=pg_fetch_row($query);
if(!empty($_FILES['cargadisciplinarios'])){
if(!empty($_FILES['cargadisciplinarios'])){
$cargadisciplinarios=$obj->cargar_archivo($_FILES['cargadisciplinarios']['name'][$i],$_FILES['cargadisciplinarios']['type'][$i],$_FILES['cargadisciplinarios']['size'][$i],$_FILES['cargadisciplinarios']['tmp_name'][$i],$_FILES['cargadisciplinarios'],$rutaarchivo,$iddatospersonales,'DISCIPLINARIO',$cedula);
try {
$filedisciplinario=$cargadisciplinarios['filename'];
} catch (Exception $e) {
echo "NO ES UN ARCHIVO VÁLIDO";
$filedisciplinario="";
}
}
}
I have a select that depending on the user's choice is enabled or disabled the other select (The Cause):
The problem or the error I have is that when doing the following validation:
if (empty($_POST['causa'][$i])) {
$_POST['causa'][$i]=-1;
}
If that variable does not arrive as a result, you should bring me -1 in the cause, but that is not the problem, but in the order that it is brought to me, it is not the correct one because it arrives last. , when in reality I should get this image first annex to make it easier to understand: