Jump to content

[SOLVED] Math Issue


2K

Recommended Posts

$f1 = 300;
$y1 = 200;
$yatk = 75;
$fdef = 125;
$y3 = $y * $y2;
$f3 = $f * $f2;

The code functions 100% fine when the numbers entered into the text box (which is where $y and $f come from) are odd. It will work fine if $y is even (20, 22, 24) and $f is the next number (21, 23, 25).

 

If $y = ODD and $f = EVEN it won't work. And if it's 2 even numbers it won't work.

 

 

So, question is: how do I get it to make...

1. 2 even numbers work

2. Odd ($y) and Even ($f) numbers work

Link to comment
https://forums.phpfreaks.com/topic/157750-solved-math-issue/
Share on other sites

In an error of mine (quickly trying to change the variables into something less...confusing), I seem to have put a 2 where the 1 should be. I know it _should_ work, but something is wrong.

 

New updated code...still same issues...

$f1 = 300;
$y1 = 200;
$yatk = 75;
$fdef = 125;
$y3 = $y * $y1;
$f3 = $f * $f1;

Link to comment
https://forums.phpfreaks.com/topic/157750-solved-math-issue/#findComment-832058
Share on other sites

Maq, I don't think the OP post all of his code. $y and $f as stated came from some input fields. I assume he used the correct $_GET, $_POST, $_REQUEST or filter_input() to get the information.

 

Right, my bad, need to get some sleep...

 

So OP, if there are 1 or more even numbers then it won't work...?  Like everyone else said, you may want to post some more code and elaborate on what, "it won't work" means.

Link to comment
https://forums.phpfreaks.com/topic/157750-solved-math-issue/#findComment-832149
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.