Problemas para procesar y mostrar datos de un array
Publicado por Adrián (4 intervenciones) el 30/03/2019 16:45:18
Estoy trabado de como resolver este script, pido cantidad de notas y quieros almacenar en un array dichos valores para luego sacar un promedio. No se como acceder al array y si esta bien hecho el paso de datos desdel el formulario al array "n2" en este caso. Saludos, muchas gracias
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> *NOTAS Y PROMEDIO *</title>
</head>
<body style=<'background-color:blue'>
<fieldset>
<legend> NOTAS DE PARCIALES </legend>
<form action="NOTAS.php" method="POST">
CANTIDAD DE NOTAS EVALUADAS <input type='number' name="n1" value="" > </br>
<input type='submit' name='Enter'>
<br>
<br> <br>
</form>
</fieldset>
<form action ="NOTAS.php" method="POST" >
<?php if(isset($_POST["n1"])){?>
<?php for ($i=1;$i<=$_POST["n1"];$i++) {?>
<input type='number' name="n2[]" placeholder="Nota"> <br>
<?php } ?>
<?php } ?>
<input type="submit" name="Calcular">
<br>
<?php
//echo array_sum($n2) ;
$n2=$_POST['n2'];
echo $n2;
?>
</form>
</body>
</html>
Valora esta pregunta


0