Generate CSV with multiple records with a single Form

0

how are you? I tell you that I am new to the Program ... I need to create a csv with n rows or records using the same Form ... at the moment I have the following code which generates this csv but only with 1 record when using the submit button . I would need to add more records before generating said csv file.

    if(isset($_POST['generaCSV'])){

//collect form data
$inpNombre = $_POST['inpNombre'];
$inpDeployState = $_POST['inpDeployState'];
$inpIncidentState = $_POST['inpIncidentState'];
$inpRespTecnico = $_POST['inpRespTecnico'];
$inpRespServicio = $_POST['inpRespServicio'];
$inpSistOp = $_POST['inpSistOp'];
$inpClteProy = $_POST['inpClteProy'];
$inpIp = $_POST['inpIp'];
$inpPropFunc = $_POST['inpPropFunc'];
$inpObserv = $_POST['inpObserv'];


//Chequea el cambo Nombre
if($inpNombre ==''){
    $error[] = 'Se requiere ingresar el Nombre corto de la VM (Sin Dominio)';
}

//if no errors carry on
if(!isset($error)){

    # Titulos de columnas CSV
    $Content = "Name;\"Deployment State\";\"Incident State\";\"Responsable_Tecnico\";\"Responsable_del_Servicio\";\"Sistema_Operativo\";\"Cliente_o_Proyecto\";\"IP\";\"Proposito/Funcion\";\"Observaciones\"\n";

    //establecer los datos del CSV
    $Content .= "$inpNombre;\"$inpDeployState\";\"$inpIncidentState\";\"$inpRespTecnico\";\"$inpRespServicio\";\"$inpSistOp\";\"$inpClteProy\";\"$inpIp\";\"$inpPropFunc\";\"$inpObserv\"";



    # establecer el nombre del archivo y crear el archivo CSV
    $FileName = "formdata-".date("d-m-y-h:i:s").".csv";
    header('Content-Type: application/csv');
    header('Content-Disposition: attachment; filename="' . $FileName . '"');
    
asked by Alvarez Casco 12.10.2018 в 16:04
source

0 answers