salve a tutti stavo realizzando questo programmino in php e html per sommare gli elementi di un array...solo che nella pagina finale usata per fare la somma non so come procedere per richiamare le variabili per la somma...potete aiutarmi?posto i codici:
somma.html:
codice HTML:
<head>
<title> Somma.html </title>
<body bgcolor = red>
<H1><center> Somma elementi array </center></H1>
<form action = somma.php method = "get" >
Inserisci qui la grandezza dell'array:<pre> | \_/
</pre>
<input type = "text" name = "numero" >
<input type = "submit" value = "Procedi">
</body>
</head>
somma.php:
Codice PHP:
echo "<form action = somma1.php method = \"get\">";
if($numero == NULL)
{
print "Devi inserire un valore prima...";
echo "<H3>clicca "."<a href = \"somma.html\"> qui</a> "."per ricominciare</H3>";
}
else
{
echo "array di ".$numero." elementi <BR>";
for($i=0;$i<$numero;$i++)
{
echo "Inserisci il valore [".$i."]";
echo "<input type = text name = \"valore$i\" >";
echo "<br>"; }
print "<input type = \"submit\" value = \"Somma\" >";
}
somma1.php:
Codice PHP:
$valore = $_GET['$valore$i'];
$somma = $somma + $valore[$i];
echo "Somma = " .$somma;