Rounding a number up
Moderator: General Moderators
-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm
Rounding a number up
I need to be able to round a number up. I looked at the round() function, but is it possible to round it up.
i.e. 3.1 -> 4 , 3.9-> 4
i.e. 3.1 -> 4 , 3.9-> 4
-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm
ok, i have a problem
this is the error i get: Parse error: parse error, unexpected T_IF, expecting ',' or ';' in /home/nokiddin/public_html/bankingcalc2.php on line 27
any ideas?
Code: Select all
<?
$attackgold = $_POSTї'attackgold'];
$defencegold = $_POSTї'defencegold'];
$menuattack = $_POSTї'attack'];
$menudefence = $_POSTї'defence'];
$attackweapons = $attackgold/$attack;
$defenceweapons = $defencegold/$defence;
echo "<p><strong><font size="6">UNDER CONSTRUCTION</font></strong></p>"
if ($attackweapons > 0){
echo "ceil($attackweapons)";
}else {"";
}
if ($defenceweapons > 0) {
echo "ceil(defenceweapons)";
}else {"";
}
?>any ideas?
Code: Select all
<?
$attackgold = $_POSTї'attackgold'];
$defencegold = $_POSTї'defencegold'];
$menuattack = $_POSTї'attack'];
$menudefence = $_POSTї'defence'];
$attackweapons = $attackgold/$attack;
$defenceweapons = $defencegold/$defence;
echo "<p><strong><font size="6">UNDER CONSTRUCTION</font></strong></p>"
if ($attackweapons > 0){
echo ceil($attackweapons);
}else {
echo"";
}
if ($defenceweapons > 0) {
echo ceil(defenceweapons);
}else {
echo "";
}
?>-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm
Code: Select all
<?
$attackgold = $_POSTї'attackgold'];
$defencegold = $_POSTї'defencegold'];
$menuattack = $_POSTї'attack'];
$menudefence = $_POSTї'defence'];
if ($attackgold = 0){
echo "";
}else{
$attackweapons = $attackgold/$attack;
echo "ceil ($attackweapons)";
}
if ($defencegold = 0){
echo "";
}else{
$defenceweapons = $defencegold/$defence;
echo "ceil ($defenceweapons)";
}
echo "<p><strong><font size="6">UNDER CONSTRUCTION</font></strong></p>";
?>i am looking for numbers, you can visit the site at http://nokidding.websiteallies.com/bankingcalc.html , check the bottom part, thats the one i am having trouble with.
-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm
-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm
new code
this code now works, although when it outputs the numbers it doesnt round up, it says ceil(1.77777) or something. Do i have the proper syntax?
Code: Select all
<?
$attackgold = $_POSTї'attackgold'];
$defencegold = $_POSTї'defencegold'];
$menuattack = $_POSTї'attack'];
$menudefence = $_POSTї'defence'];
if ($attackgold != 0){
$attackweapons = $attackgold/$attack;
echo "ceil ($attackweapons)";
}else{
echo "";
}
if ($defencegold != 0){
$defenceweapons = $defencegold/$defence;
echo "ceil ($defenceweapons)";
}else{
echo "";
}
echo "<p><strong><font size="6">UNDER CONSTRUCTION</font></strong></p>";
?>- smpdawg
- Forum Contributor
- Posts: 292
- Joined: Thu Jan 27, 2005 3:10 pm
- Location: Houston, TX
- Contact:
Don't echo the ceil function inside " ". Double quotes are for displaying string literals, you are trying to output the value of a function.
Wrong
Right
Wrong
Code: Select all
echo "ceil ($defenceweapons)";Code: Select all
echo ceil ($defenceweapons);-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm