首页 > 解决方案 > 我无法让我的 php 添加我需要添加的所有内容

问题描述

我正在尝试将 if 语句添加到 the$totalReimb以及 the$totalMileReimb但似乎无法让它们仅$totalMileReimb添加

变量

    $ratePerMile = 0.35;
    $miles = $_POST['miles'];
    $bfast = $_POST['bfast'];
    $lunch = $_POST['lunch'];
    $dinner = $_POST['dinner'];
    $hotel = $_POST['hotel'];
    $totalMileReimb = $miles * $ratePerMile;
    $totalReimb = 0 + $totalMileReimb;
    $Yes = "Yes";
    $No = "No";

If 语句

    if ($miles < 1 or $miles > 3000){
        // input error message
        print ("<p> Input Error, Try Again! </p>");
        // link back to the form
        print ("<a href=\"juarez-biz-travel.html\">Return to form</a>");
    } else {
        if ($miles >=10 or $miles <= 3000 );{
            if ($bfast == $Yes) $totalReimb + 8.50;
            if ($lunch == $Yes) $totalReimb + 12.50;
            if ($dinner == $Yes)$totalReimb + 18.50;
            if ($hotel == $Yes) $totalReimb +  110.00;
        }
        print ("<p> The Total Is $$totalReimb! </p>");
    }

标签: phpvariablesif-statement

解决方案


我认为你的错误是这样的,$totalReimb + 12.50应该是以下之一:

  • $totalReimb = $totalReimb + 12.50
  • $totalReimb += 12.50.

推荐阅读