Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP/MySQL - Decimal Feild - Comma

Featured Replies

Hi folks,

 

In a little bit of a pickle and need some assistance. I've been working on a site for an estate agent, i have made it completely from scratch, which i'm pretty chuffed about as i've never taken on a project of such scale.

 

However, there is a very small problem that is driving me insane, I have a Decimal field in my database to hold the price of each house.

 

When for example i enter 10,000 only 10 is entered into the field. So i just wrote 10000 to overcome this....how now, do i get it to output as 10,000?

 

I hope that made sense, some help would be much appreciated, its frustrating that such a small thing is causing such a big problem!!!

 

Thanks in advance.

  • Author

Thanks, i was just looking at that actually.

 

I tried:

 

$number = ".$row[10].";

$english_format_number = number_format($number);

echo " £ ".$english_format_number." ";

 

This i would have expected to output £23,000 as 23000 is the value in the database, however, it output £0.23

 

Any ideas what i need to change?

 

Thanks again.

In the DECIMAL field in the DB you want the 'Length/Values' set to '10,2'

 

Try that

  • Author

Thanks very much folks.

 

The solution was pretty much a combination of each.

 

$number = $row[10];

$pr = number_format($number);

echo " £ ".$pr." ";

 

(and i also set row 10 , Decimal to 10,2)

 

Thanks again! :-D

Would this work for you too?

 

echo ' £ '. number_format($row[10]);

  • Author

Yea, that would probably be a more efficient way of doing it :-D

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.