Can a form be sent for each value of an arrray?

0

I want to build a function in php so that I send a form for each of the values of an array.

Next I put the code that I have made:

   function importar () { 

$productos = ($_SESSION ['CSVpart']);  //El array lo tenemos como variable de sesion.


    foreach ($productos as $valor){
                $csv = $valor; ?>

<div id="enviarFormCsv">

<form method="POST" action ="POST.php" name="enviaCsv" > <input type
="hidden"  name="csv" value="<?php echo $csv ?>"> <input type="submit" value="Confirmar la importación a Prestashop"> </form>

</div> <!--Cierra div EnviaFormCsv.-->

<?php
}   //Cierra foreach. 
}  // Cierra la funcion.

Well, with this code, only the first value of the array is received.

What is needed is to send (and receive) a form for each value of the array

    
asked by JOMU 15.09.2017 в 04:04
source

1 answer

0

enter the code here

<form name="enviandoCsv" method="POST" action ="pagina_recepcion.php"> 
<?php
            $i = 0;
           foreach($productos as $value){ 
?>
            <input type ="text" name="<?='csv' . $i?>" value="<?= $value ?>" hidden>
 <?php
           $i++;
           } //Cierra foreah
?>
            <input type="submit" value="Confirmar Importación">
        </form>

<?php
    
answered by 27.09.2017 в 22:10