What do I use for a variable which will count the total amount?
For example
if ($featured == "1"){
$cos开发者_StackOverflow社区t = 100;
}else{
$cost = 1000;
}
Basically each time that is looped, we display the $cost
on page, but I also want to set aside a variable $total
which adds up each $cost
as the loop runs.
I'm sorry, but really?
$total = 0; // this somewhere before the loop
// start loop
if ($featured == "1") {
$cost = 100;
} else {
$cost = 1000;
}
$total += $cost;
// end loop
精彩评论