我有一个简单的计算器表格,要求提供基本预算信息。
用户名、Paycheck 1 金额、Paycheck 2 金额、租金、水电费......
不知何故,我需要单独计算所有费用字段占总收入的百分比。我只是不确定该怎么做。我已经阅读了大量的教程,即使使用源文件也没有。
这是我的处理 php。当然可以在正确的方向上使用推动力。谢谢!
<?php
if ($_POST['sum1'] == "yes")
{
$name = $_POST['name'];
$month = $_POST['month'];
$year = $_POST['year'];
$pay1 = $_POST['pay1'];
$pay2 = $_POST['pay2'];
$other1 = $_POST['other1'];
$other2 = $_POST['other2'];
$rent = $_POST['rent'];
$repair = $_POST['repair'];
$utility = $_POST['utility'];
$invest = $_POST['invest'];
$insure = $_POST['insure'];
$groceries = $_POST['groceries'];
$student = $_POST['student'];
$travel = $_POST['travel'];
$ccard1 = $_POST['ccard1'];
$ccard2= $_POST['ccard2'];
$cell = $_POST['cell'];
$cable = $_POST['cable'];
$misc1 = $_POST['misc1'];
$misc2 = $_POST['misc2'];
$ttl_inc = $pay1+$pay2+$other1+$other2;
$ttl_exp = $rent+$repair+$utility+$invest+$insure+$travel+$ccard1+$ccard2+$cell+$cable+$misc1+$misc2+$student+$groceries;
$total = $pay1+$pay2+$other1+$other2-$rent-$repair-$utility-$invest-$insure-$travel-$ccard1-$ccard2-$cell-$cable-$misc1-$misc2-$student-$groceries;
echo "<h2>Budget Recap Prepared For {$name} For Period: {$month} {$year}</h2> <br />";
echo "<br />";
echo "<h3>Income</h3> <br />";
echo "<br />";
echo "Pay Period 1: $ {$pay1} <br />";
echo "Pay Period 2: $ {$pay2} <br />";
echo "Other Income 1: $ {$other1} <br />";
echo "Other Income 2: $ {$other2} <br />";
echo "<strong>TOTAL INCOME: $ {$ttl_inc} </strong><br />";
echo "<br />";
echo "<h3>Expenses</h3> <br />";
echo "<br />";
echo "Rent: $ {$rent} <br />";
echo "Utilities: $ {$utility} <br />";
echo "Groceries: $ {$groceries} <br />";
echo "Insurance: $ {$insure} <br />";
echo "Credit Card 1: $ {$ccard1} <br />";
echo "Credit Card 2: $ {$ccard2} <br />";
echo "Repairs/Maintenance: $ {$repair} <br />";
echo "Savings/Investments: $ {$invest} <br />";
echo "Student Loans: $ {$student} <br />";
echo "Transportation: $ {$travel} <br />";
echo "Cell/Mobile Phone: $ {$cell} <br />";
echo "Cable/Internet/Other: $ {$cable} <br />";
echo "Other Expenses 1: $ {$misc1} <br />";
echo "Other Expenses 2: $ {$misc2} <br />";
echo "<strong>TOTAL EXPENSES: $ - {$ttl_exp} </strong><br />";
echo "<br />";
echo "<strong>NET INCOME FOR {$month} {$year} : $ {$total} </strong><br />";
}
?>