php Form Request for Data Sum Example
- 2021-06-28 11:26:41
- OfStack
Get the value of the form request:
Case:
request.php
Case:
request.php
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8;" />
<title> Compute Request </title>
</head>
<body>
<form action="result.php" method="post">
<input type="text" name="grade"/>
<input type="submit" value=" Start calculation "/>
</form>
</body>
</html>
[code]
result.php
[code]
<?php
$grade=$_REQUEST['grade'];//grade--> And in forms name value 1 kind
$arr=explode(" ",$grade);// Split the string with spaces and get the array result
print_r($arr);
$res=0;
for($i=0;$i<count($arr);$i++){
$res+=$arr[$i];
}
echo "<br/>ALL=".$res;
echo "<br/>AVG=".(round($res/count($arr),0));//round(12.334,2)//4 Shell 5 Method of entry
?>