LuciferStar 0 Report post Posted August 9, 2004 <?php[br]if($_REQUEST['NUM']!=0)[/br]{[br]?>[/br] <form method=post>[br]<?php[/br] for($i=0;$i<$_REQUEST['NUM'];$i++)[br] echo "field".($i+1)." <input type=text name="."field".($i+1)." value=".$_POST['field'.($i+1).'']."><BR>";[br]?>[/br] <INPUT TYPE=SUBMIT>[/br] </form>[br]<?PHP[/br] for($i=0;$i<$_REQUEST['NUM'];$i++)[br] $sum+=$_POST['field'.($i+1).''];[/br] echo "SUM:\t".$sum."<BR>"."AVERAGE:\t".$sum/$i;[br]}[/br]?> Share this post Link to post Share on other sites
LuciferStar 0 Report post Posted August 9, 2004 <?php[br]if($_REQUEST['NUM']!=0)[/br]{[br]?>[/br] ? <form method=post>[br]<?php[/br] ? for($i=0;$i<$_REQUEST['NUM'];$i++)[br] ? ? ?echo "field".($i+1)." <input type=text name="."field".($i+1)." ? ? ? ? ? ? ? ? ? ? ?value=".$_POST['field'.($i+1).'']."><BR>";[br]?>[/br] ? <INPUT TYPE=SUBMIT>[/br] ? </form>[br]<?PHP[/br] ? for($i=0;$i<$_REQUEST['NUM'];$i++)[br] ? ? ?$sum+=$_POST['field'.($i+1).''];[/br] ? echo "SUM:\t".$sum."<BR>"."AVERAGE:\t".$sum/$i;[br]}[/br]?> Usage:sum.php?NUM=100 to calculate the sum and average of 100 students' scores Share this post Link to post Share on other sites