CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   Need some help with a php calc? (http://www.codingforums.com/showthread.php?t=284051)

Gaogier 12-12-2012 09:50 PM

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.

Fumigator 12-13-2012 12:03 AM

Did you write this code?

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

Gaogier 12-13-2012 01:05 AM

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 ":D" 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']); 


lewisstevens1 12-13-2012 11:31 AM

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?

lewisstevens1 12-13-2012 11:46 AM

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



All times are GMT +1. The time now is 07:06 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.