The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Outputting mysql db fields as formated #s, Using multi-row'd db selections and multi-fields, format the outpu
WotCGM
post Nov 11 2012, 02:29 AM
Post #1





Group: Members
Posts: 1
Joined: 11-November 12
Member No.: 18,092



Hello All.

I have a db-table in mysql that has 18 fields in it. Of those, 2 are badly formated... ie not at all.
They show up as 1234567890123 .
The data type is bigint.

When I do my select statement in php, I come up with 30 rows of data (proper), but in each
case, the two "badly formated" fields also show up that way.

I would like them to show up as: 1,234,567,890,123 for example.

So, this is both a php and mysql question. smile.gif

Thanks in advance..

Larry

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Ephraim F. Moya
post Dec 17 2012, 08:29 AM
Post #2


Advanced Member
****

Group: Members
Posts: 167
Joined: 2-September 07
From: New Mexico
Member No.: 3,702



QUOTE(WotCGM @ Nov 11 2012, 01:29 AM) *

Hello All.

I have a db-table in mysql that has 18 fields in it. Of those, 2 are badly formated... ie not at all.
They show up as 1234567890123 .
The data type is bigint.

When I do my select statement in php, I come up with 30 rows of data (proper), but in each
case, the two "badly formated" fields also show up that way.

I would like them to show up as: 1,234,567,890,123 for example.

So, this is both a php and mysql question. smile.gif

Thanks in advance..

Larry



php has a command called 'number_format' which will format numbers like you want.

http://php.net/manual/en/function.number-format.php

you can't do it in mySQL unless you change the field type from bigint to string.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 05:07 PM