Jump to content

Recommended Posts

Hello, i am currently making a small game type thing and i want to have a money field... I have tried a few different field types to get exactly what i want but nothing seems to be working... i want to save money so its in the form 1,000,000 and then 560,000,000 e.t.c. so its easy to read for people... none of the int field types support the ',' as far as i know and ive tried a few thats its not working for...

 

i decided that i should just use VarChar and enter 1,000,000 then echo that out to show ammount of cash i got and...it works!!

 

However, i i have now started to use this field in code and im trying to check if i have enough cash by basicly doing code like this:

 

if($mymoney < $neededmoney)
{
echo "test";
}

 

However this is not working because i THInk its just thinks that the value of $mymoney is 1 (1,000,000)...Wen i type use 1 for the number then test will Show up however if i type 2 then it wont show.. (i think...im confusing myself)

 

so anything i need a way of saving 1,000,000 as the number 1000000 - also ive tried useing INT for 1000000 but then it STILL just saves it as 1...when i echo this out it even shows it as '1' not '1000000'...

 

any help would be great!

Link to comment
https://forums.phpfreaks.com/topic/184131-setting-up-a-money-field/
Share on other sites

so its easy to read for people...

When you display it, you format it with the 1,000 thousands separators. There is both a mysql FORMAT() function that you can use in a query and a php number_format() function that you can use in your presentation logic.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.