基本上我試圖將值相乘。通過Javascript和PHP添加數字值
下面我有一個UL是echo'ing出一個數值,:
<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 the_field('average_drinks_spenditure_per_night'); ?></li>
<li><span>Average drinks spenditure for the year</span> <!-- JAVA BIT --></li>
<li><span>Average drinks spenditure for 3 years</span> <!-- JAVA BIT --></li>
</ul>
我想要的第三利獲得第二個裏的值,然後正好28
乘以該數值我再想第四李拿到第三李的價值,並乘上3
如此這般有點像這樣:
麗2×28 =麗3 li-3 x 3 = li-4
如果這樣做有道理? li1和li2的值將通過該PHP字段生成,對此有任何幫助,因爲我不知道從哪裏開始?
更新PHP測試:
<?php
var_dump(the_field('average_drinks_spenditure_per_night'));
$li2 = the_field('average_drinks_spenditure_per_night');
$li3 = ($li2 * 28) * 2.1;
$li4 = $li3 * 3;
?>
<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>
什麼是'the_field'?爲什麼你不能只回應這個計算的結果,因爲你已經有了這些值......我很困惑..... – thatidiotguy
如果你有一個變量'var',你肯定可以在下一行使用它。 VAR * 28。 –
是字段變量?不應該是$ the_field。 –