Jump to content
xisto Community
LuciferStar

to know average and sum I want to know the students score

Recommended Posts

<?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

<?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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.