我正在尝试制作一个Stableford高尔夫计分系统,在该系统中,球员输入他们的击球次数,这就是他们打进洞的击球次数。对于每个孔,都有一个单独的点。由于有9个洞,因此有9个单独得分。我已经可以使系统回显每个孔的每个点。现在,我遇到的问题是,如何对所有九个回波求和并显示总结果?
这是pointhole9的if else语句
<?php
if(isset($_POST['submit'])){
$number9=$_POST["number9"];
if ($number9 == "4") {
echo "Points hole 9: <input type='number' name='pointhole9'
id='pointhole9' value='2'/>";
} elseif ($number9 == "5") {
echo "Points hole 9: <input type='number' name='pointhole9'
id='pointhole9' value='1'/>";
} elseif ($number9 >="6") {
echo "Points hole 9: <input type='number' name='pointhole9'
id='pointhole9' value='0'/>";
} elseif ($number9 == "3") {
echo "Points hole 9: <input type='number' name='pointhole9'
id='pointhole9' value='3'/>";
} elseif ($number9 <= "2") {
echo "Points hole 9: <input type='number' name='pointhole9'
id='pointhole9' value='4'/>";
}
}
?>
这就是我试图将回声加起来的方式
<?php
if(isset($_POST['submit'])){
$pointhole1 =$_POST['pointhole1'];
$pointhole2 =$_POST['pointhole2'];
$pointhole3 =$_POST['pointhole3'];
$pointhole4 =$_POST['pointhole4'];
$pointhole5 =$_POST['pointhole5'];
$pointhole6 =$_POST['pointhole6'];
$pointhole7 =$_POST['pointhole7'];
$pointhole8 =$_POST['pointhole8'];
$pointhole9 =$_POST['pointhole9'];
$sum =
$pointhole1+$pointhole2+$pointhole3+$pointhole4+$pointhole5+
$pointhole6+
$pointhole7+$pointhole8+$pointhole9;
echo $sum;
}
?>
使用if else语句,输出将有所不同。我只是在寻找如何汇总这些点孔。