ERuiz Posted January 10, 2007 Share Posted January 10, 2007 I have the following problem:[code]$sqlfield13 = "SELECT field13 FROM vb3_userfield WHERE userid = '".$IDPilot."' ";$Resultfield13 = $MyDb->f_ExecuteSql($sqlfield13);$PrevHours = $MyDb->f_GetRecord($Resultfield13);$PrevHours = $PrevHours['field13'];$PrevHours = number_format($PrevHours); if ($PrevHours >= 100) { $PrevHours = 50; } else { $PrevHours = 0; }[/code]In the case above, I get the following results:if field13 = 234.3 then $PrevHours = 50if field13 = 72.3 then $PrevHours = 0if field13 = 1,023.3 then $PrevHours = 0How come the last situation is giving the wrong result?Regards,ERuiz Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted January 10, 2007 Share Posted January 10, 2007 why must you insert the comma's in the first place? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 10, 2007 Share Posted January 10, 2007 number_format is only for when you need to print them out or turn them into strings. If you want to keep doing math with a number (or do comparisons in which it is a number), no commas allowed. Don't use number_format up there. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.