下面我有很多使用PHP創建的添加和值。添加PHP問題
它一切正常!在這裏可以看到:http://universitycompare.com
EXCEPT - 第一組PHP中有'$ totalcost'。我似乎無法弄清爲什麼我的值在下面創建的不能用於創建總數。
有沒有意見?
<?php
$totalcost = $totalcost2 + $totalcost3;
$totalcost2 = $li444 + $tuitionTotal;
$totalcost3 = $li4 + $li44;
?>
<!-- WORKING OUT TOTAL TCE -->
<p>
<b class="TCE">
<?php echo $totalcost; ?>
<?php echo array_sum($a); ?>
</b>
</p>
<!-- END OF WORKING OUT TOTAL TCE -->
<br /><br />
<h2>
Below is a a breakdown of the total cost of Education:
</h2>
<?php
$li2 = get_field('average_drinks_spenditure_per_night');
$li3 = ($li2 * 28) * 2.1;
$li4 = $li3 * 3;
?>
<div class="TCE">
<br />
<h2>Average spent on socialising</h2>
<ul class="TCE">
<li><span>Average drink cost</span> £<?php echo the_field('average_drink_price'); ?></li>
<li><span>Average drinks spenditure per night</span> £<?php echo $li2; ?></li>
<li><span>Average drinks spenditure for the year</span> £<?php echo $li3;?><!-- JAVA BIT --></li>
<li><span>Average drinks spenditure for 3 years</span> £<?php echo $li4;?><!-- JAVA BIT --></li>
</ul>
<?php
$li22 = (get_field('average_housing_costs_per_week') * 4);
$li33 = $li22 * 12;
$li44 = $li33 * 3;
?>
<h2>Average spent on living costs</h2>
<ul class="TCE">
<li><span>Housing per week</span> £<?php echo the_field('average_housing_costs_per_week'); ?></li>
<li><span>Housing per month</span> £<?php echo $li22; ?></li>
<li><span>Housing per year</span> £<?php echo $li33; ?></li>
<li><span>Housing for 3 years</span> £<?php echo $li44; ?></li>
</ul>
<div class="clear"></div>
<p><br /></p>
<?php
$li222 = (get_field('average_shopping_trip_price') * 2.25);
$li333 = $li222 * 12;
$li444 = $li333 * 3;
?>
<h2>Average spent on food shopping</h2>
<ul class="TCE">
<li><span>Average shopping trip </span> £<?php echo the_field('average_shopping_trip_price'); ?></li>
<li><span>Average shopping for the month</span> £<?php echo $li222; ?></li>
<li><span>Average shopping for the year</span> £<?php echo $li333; ?></li>
<li><span>Average shopping for 3 years</span> £<?php echo $li444; ?></li>
</ul>
<?php
$tuitionClass = (get_field('tuition_fees') /28);
$tuitionTotal = (get_field('tuition_fees') * 3);
?>
<h2>Average spent on tuition</h2>
<ul class="TCE">
<li><span>Price per Week</span> £<?php echo $tuitionClass; ?></li>
<li><span>Average tuition fee</span> £<?php echo the_field('tuition_fees'); ?></li>
<li><span>Average tuition fee for 3 years</span> £<?php echo $tuitionTotal; ?></li>
</ul>
如果我明白你的問題是你應該添加2個總成本後,你給他們一個價值,而不是之前。 –