如何使用php$\u post对两个结果求和

如何使用php$\u post对两个结果求和,php,post,sum,Php,Post,Sum,我想求结果1和结果2的和 我该怎么做请帮我解决这个问题 谢谢 例如: $res+res1 =最终结果 这是结果1代码 <?php //Starting of php if(isset($_POST['submit']))//if the submit button has pressed { $first = $_POST['first']; //Getting Value of first integer from add.html $sec = $_

我想求结果1和结果2的和 我该怎么做请帮我解决这个问题

谢谢


例如: $res+res1 =最终结果

这是结果1代码

<?php //Starting of php 
    if(isset($_POST['submit']))//if the submit button has pressed
    {
    $first = $_POST['first']; //Getting Value of first integer from add.html
    $sec = $_POST['sec']; //Getting Value of Second integer from add.html
    $res = $first * $sec *75 /365 /30; //Adding the two values and placing the added result to 'res' variable
    echo 'Added Result:';

    echo number_format((round($res, 1)),3);


    }
    //Ending of php
    ?>

这是第二个结果代码

<?php //Starting of php 
if(isset($_POST['submit']))//if the submit button has pressed
{
$days1 = $_POST['days1']; //Getting Value of first integer from add.html
$year1 = $_POST['year1']; //Getting Value of Second integer from add.html
$res1 = $days1 * $year1 *75 /365 /30; //Adding the two values and placing the added result to 'res' variable
echo 'Added Result:';

echo number_format((round($res1, 1)),3);


}
//Ending of php
?>

试试这个

<?php //Starting of php 
    if(isset($_POST['submit']))//if the submit button has pressed
    {
    $first = $_POST['first']; //Getting Value of first integer from add.html
    $sec = $_POST['sec']; //Getting Value of Second integer from add.html
    $days1 = $_POST['days1']; //Getting Value of first integer from add.html
    $year1 = $_POST['year1']; //Getting Value of Second integer from add.html
    $res1 = $days1 * $year1 *75 /365 /30; //Adding the two values and placing the added result to 'res' variable    
    $res = $first * $sec *75 /365 /30; //Adding the two values and placing the added result to 'res' variable
    $result1  = number_format((round($res1, 1)),3);
        echo 'Added Result:';

    $result2 = number_format((round($res, 1)),3);
    echo $final_result   = number_format(($result1 +$result2),3);

    }
    //Ending of php
    ?>

试试这个

<?php //Starting of php 
    if(isset($_POST['submit']))//if the submit button has pressed
    {
    $first = $_POST['first']; //Getting Value of first integer from add.html
    $sec = $_POST['sec']; //Getting Value of Second integer from add.html
    $days1 = $_POST['days1']; //Getting Value of first integer from add.html
    $year1 = $_POST['year1']; //Getting Value of Second integer from add.html
    $res1 = $days1 * $year1 *75 /365 /30; //Adding the two values and placing the added result to 'res' variable    
    $res = $first * $sec *75 /365 /30; //Adding the two values and placing the added result to 'res' variable
    $result1  = number_format((round($res1, 1)),3);
        echo 'Added Result:';

    $result2 = number_format((round($res, 1)),3);
    echo $final_result   = number_format(($result1 +$result2),3);

    }
    //Ending of php
    ?>


你说的是求和,你做的是$first*$sec*75/365/30,所以问题不清楚这些在同一页或不同的文件上?为什么乘法被描述为“加法”?那么你问的答案有什么问题,并接受了20分钟。ago?亲爱的@Fred ii-这是不同的问题,这就是为什么我问你说的是sum,你做的是$first*$sec*75/365/30,所以问题不清楚,这些是在同一页还是不同的文件上?为什么乘法被描述为“加法”?那么你问的答案有什么问题,并且接受了20分钟。前?亲爱的@Fred ii-这是不同的问题,这就是为什么我问zeeshan你能给我你的fb电子邮件id吗?你可以在我的个人资料上看到,如果这个答案有助于你接受。zeeshan你能给我你的fb电子邮件id吗?你可以在我的个人资料上看到,如果这个答案有助于你接受。