Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 105,772 PHP Programmers for FREE! Ask your question and get quick answers from experts. There are 1,462 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Need help with a function

 
Reply to this topicStart new topic

Need help with a function

modern6
post 11 Jul, 2008 - 02:58 PM
Post #1


New D.I.C Head

*
Joined: 11 Jul, 2008
Posts: 19


My Contributions


Well i need a code so i can have like a decimal place for rank% like 99.356% but i dont know what i need for a dot i know makecomma but i want a dot
CODE
<? echo  "".makecomma($percent).""; ?>%
User is offlineProfile CardPM

Go to the top of the page


JBrace1990
post 11 Jul, 2008 - 03:01 PM
Post #2


D.I.C Regular

Group Icon
Joined: 9 Mar, 2008
Posts: 293



Thanked 10 times

Dream Kudos: 350
My Contributions


a few things first... with the way you're doing it, you don't need the 4 " and 2 periods...

Try using Number Format and see if it comes up right =)
User is offlineProfile CardPM

Go to the top of the page

modern6
post 11 Jul, 2008 - 03:09 PM
Post #3


New D.I.C Head

*
Joined: 11 Jul, 2008
Posts: 19


My Contributions


The link did not work sad.gif

also i took 4" and 2. off

This post has been edited by modern6: 11 Jul, 2008 - 03:11 PM
User is offlineProfile CardPM

Go to the top of the page

gabehabe
post 11 Jul, 2008 - 03:27 PM
Post #4


T3H R0XX0R!

Group Icon
Joined: 6 Feb, 2008
Posts: 2,054



Thanked 40 times

Dream Kudos: 1425

Expert In: C, C++

My Contributions


It depends where you're from. JBrace's was prefixed with us3, but if I go on it, it gets prefixed with uk3.

Try just going to http://php.net/number_format

That should automatically redirect you smile.gif
User is online!Profile CardPM

Go to the top of the page

modern6
post 11 Jul, 2008 - 03:32 PM
Post #5


New D.I.C Head

*
Joined: 11 Jul, 2008
Posts: 19


My Contributions


CODE
<?php
$retard1 = mysql_query("SELECT `rankpoints`, `rank` FROM `users` WHERE `username`='$username'");
while($retard = mysql_fetch_row($retard1)){
    $rankp= $retard[0];
$currank= $retard[1];

}
$query=mysql_query("SELECT * FROM users WHERE username='$username'");
$fetch=mysql_fetch_object($query);

$query1=mysql_query("SELECT * FROM user_info WHERE username='$username'");
$info=mysql_fetch_object($query1);

$currank=$fetch->rank;
$rankp = $fetch->rankpoints;

if ($currank == "Scum"){
$max = "40";
$old="0";
}elseif ($currank == "Tramp"){
$max = '200';
$old="40";
}elseif ($currank == "Crook"){
$max = '800';
$old="200";
}elseif ($currank == 'Thief'){
$max = '1600';
$old="800";
}elseif ($currank == "Druglord"){
$max = '2600';
$old="1600";
}elseif ($currank == "Gangster"){
$max = '4200';
$old="2600";
}elseif ($currank == "Mobster"){
$max = '5600';
$old="4200";
}elseif ($currank == "Soldier"){
$max = '7200';
$old="5600";
}elseif ($currank == "General"){
$max = '9000';
$old="7200";
}elseif ($currank == "Local Boss"){
$max = '18000';
$old="9000";
}elseif ($currank == "Boss"){
$max = '36000';
$old="18000";
}elseif ($currank == "Assasin"){
$max = '72000';
$old="36000";
}elseif ($currank == "Capo Bastone"){
$max = '144000';
$old="72000";
}elseif ($currank == "Don"){
$max = '288000';
$old="144000";
}elseif ($currank == "God Father/Mother"){
$max = '566000';
$old="288000";
}elseif ($currank == "Moderator"){
$max = '2147483647';
$old="0";
}elseif ($currank == "Co-Owner"){
$max = '2147483647';
$old="0";
}elseif ($currank == "Owner"){
$max = '2147483647';
$old="0";
}

$percent = round((($rankp-$old)/($max-$old))*100000);
?><? echo makecomma($percent); ?>%


this is for a mafia game and i want the makecomma to a decimal
User is offlineProfile CardPM

Go to the top of the page

Moonbat
post 11 Jul, 2008 - 06:59 PM
Post #6


D.I.C Head

Group Icon
Joined: 30 Jun, 2008
Posts: 100



Thanked 6 times

Dream Kudos: 400
My Contributions


Would doing something like this work?

CODE
$retard58092 = makecomma($percent);
$retard5000 = str_replace(",", ".", $retard58092);
echo $retard5000;


This post has been edited by Moonbat: 11 Jul, 2008 - 07:05 PM
User is online!Profile CardPM

Go to the top of the page

modern6
post 12 Jul, 2008 - 01:47 AM
Post #7


New D.I.C Head

*
Joined: 11 Jul, 2008
Posts: 19


My Contributions


thank you realy mutch it has worked smile.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 8/21/08 03:40PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month