Fill array in PHP with form and show results in a table

0

The problem I have is the following, I have to make a financial management platform and for that they ask me to create the variables that are, $ date, $ concept, $ amount and $ balance. The date will be a default field, the concept and quantity will be the data that the user enters and the balance will be a calculated field. The problem is that for these variables they ask me to create it in a multidimensional array which I will have to fill in with the form. I have looked at the PHP manual but I can not come up with any solution for this ... Thank you in advance to everyone !!

    
asked by Zequi27 14.10.2018 в 12:47
source

1 answer

0

This is what you need, you simply put this in a notebook, you save it with .PHP extension in the folder that executes the files of the APACHE server, you execute it with some apache emulator, I use WAMP Server

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
Fecha:
<input type="text" value="<?php echo date("Y-m-d");?>" disabled>
<input type="text" name="info[fecha]" value="<?php echo date("Y-m-d"); ?>" hidden>
<br>
Concepto:
<input type="text" name="info[concepto]" required>
<br>
Cantidad:
<input type="number" name="info[cantidad]" required>
<br>
Saldo:
<input type="text" name="info[saldo]" required>
<br>
<input type="submit" value="enviar">
</form>
<?php 
//comprueba si la variable info es creada si es que el formulario es enviado
if(isset($_POST['info'])){
$array=$_POST['info'];
$fecha=$array["fecha"];
$concepto=$array["concepto"];
$cantidad=$array["cantidad"];
$saldo=$array["saldo"];
echo "Los valores obtenidos en el formulario con Array Multidimensional es:<br>Fecha:".$fecha."<br>Concepto:".$concepto."<br>Cantidad:".$cantidad."<br>Saldo:".$saldo."";
}
?>
    
answered by 14.10.2018 в 18:31