Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: Need some help with a php calc?

1. ## Need some help with a php calc?

Hello

The following is code for a calculator, which I can't get it to display the combat level, and can't see why?

Ideally I would like someone to throw questions to while I finish the script and others beyond this small project. But any help would be great.

http://pastebin.com/YyvsG4sb

The formula for the code is simple, Defence + 2 + highest level out of Attack, Strength, Magic, Ranged, Summoning.

Anyway I can't get it to display any combat level below calculate. I am not sure why?

I have not started to work on the next part which will say how many levels of each skill (listed above) till next combat level gain.

• Did you write this code?

Your request is too broad. Can you post more specific portions of the code where the problem might lie?

• Updated code.

http://pastebin.com/0BR5Z9cQ

View the calculator here http://runehints.com/combat2

Use Gaogier - to test it.

Everything works all but the levels required to level up a combat level (at the bottom after you calculated it and it has "" in its place.

Here is the combat formula again.

Defence + 2 + highest level out of Attack, Strength, Magic, Ranged, Summoning.

I need help working out the following formula into php.

combat level - level - 2 - def level - target level (either attack, strength, magic, ranged, summoning + 1

PHP Code:
echo combatLevel(\$_POST['attack'], \$_POST['defence'], \$_POST['strength'], \$_POST['ranged'], \$_POST['magic'], \$_POST['summoning']);

• You do understand you are just calling those individual functions, echo combatLevel(\$_POST['attack'], \$_POST['defence'], \$_POST['strength'], \$_POST['ranged'], \$_POST['magic'], \$_POST['summoning']); ....
i thought you wanted to add them up?

• Oh i think i know what you are getting at... im a bit rusty although do you think something like this would work?

PHP Code:
\$combat_level \$_POST['combat_level'];
\$level \$_POST['level'];
\$attack \$_POST['attack'];
\$defence \$_POST['defence'];
\$strength \$_POST['strength'];
\$ranged \$_POST['ranged'];
\$magic \$_POST['magic'];
\$summoning \$_POST['summoning'];

\$target_level1 = array(\$attack,\$defence,\$strength,\$ranged,\$magic,\$summoning)
\$target_level2 sort(\$target_level1SORT_NUMERIC);
\$target_level3 current(\$target_level2), PHP_EOL ;

\$result \$combat_level \$level \$defence \$target_level3 1;

echo
\$result

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•