[Help!]Ratio
#1

hey guys, how can i make a ratio on my website(top list)? i'm using tkadmin right now..
i tried this code:
pawn Код:
$ratio = $row['kills'] / $row['deaths'];
and a big failed

help me plox
Reply
#2

nvm, i figured it out.
btw, i've a new problem!
for example, i've 630 kills and 162 deaths and my ratio is : 3.8888888888889
that was an epic number and my question is, how can i make it become 2 decimal point for example: 3.88?

this is my code:
Код:
if ($row['deaths'] == 0) { $ratio1 = $row['kills']; } else { $ratio1 = $row['kills'] / $row['deaths']; }
Reply
#3

Though i am not a pr0 / i dont even know, PHP , but a friend of mine once showed me a way to get selected Numbers/words or wtever from a string
it was some thing preg_match or else i dont rember
I only know this hope u get any idea :/
Reply
#4

http://php.net/manual/en/function.round.php

Check out the examples there.
Reply
#5

ok, i read all of it, i tried and still failed
can you add it to this code please:

pawn Код:
if ($row['deaths'] == 0) { $ratio1 = $row['kills']; } else { $ratio1 = $row['kills'] / $row['deaths']; }
well yea, im a noob in php :$
Reply
#6

*bump

well I tried this one: <?php echo round($ratio1, 2) ?>
failed.
what's wrong with it? :/
Reply
#7

Код:
if ($row['deaths'] == 0) { $ratio1 = $row['kills']; } else { $ratio1 = round($tkills1 / $deaths1 , 2); }
This should work.
Reply
#8

WOW!
thx a lot!! it work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)