The web script I’m using displays the User ‘balance’ amount like so: 00.00, but because the balance amount is in units, I’d like it to display as 00.0, for example 8.5, instead of 8.50.
After looking around, I see the php file showing these lines pertaining to ‘balance’:
If you declared(strict_types=1); error_reporting(-1): ini_set(‘display_errors’, ‘true’); at the top of the page script I am sure errors and warnings would highlight exactly where the problem occurs.
Sorry, if my posting was not clear, regarding “where the problem occurs”, there isn’t one. It works successfully. I’m looking for help as to how/where I can make the modification that I’ve described.
is part of an array declaration that makes it valid syntax. (ETA - his later post shows a bit more of it as part of a function call, not quite where I was thinking of).
This doesn’t seem an appropriate column type for a numeric balance.
I recall you asked before about changing the way a number was displayed, using this same template system that sits on top of the standard html. I recall you mentioned you’d sorted it, but I don’t think you said how.
To clarify, are you trying to change the way it’s stored in the database (as part of your call to $db->update() or are you trying to change the way it’s displayed? The latter would be better.
Agreed, it makes no sense to store numeric values as varchar.
Being a decimal value decimal may be a good choice of data type for that column. When you define the column format you also define the number of decimal places, along with the total number of digits (including decimals). So 0000.0 would be decimal (5, 1) that’s five digits and one decimal place, adjust the numbers to what you need, considering the maximum expected values, which in that example would be: 9999.9
Though one decimal for currency still seems odd to me as most currencies are divided into cents (or variations of).
Thanks for your reply/info.
I have followed your instructions and the ‘balance’ column structure now shows:
Type: DECIMAL
Length/Values: 5,1
Default: As Defined 0.0
yet, the html displayed number still shows as 0.00
Maybe you could comment on adding something like this:
In there, you ask about how to get it to display earnings with a decimal place, then a couple of posts later, you got it working. So perhaps you could have a look back at what you did there to make the display as you wanted.
What’s the name of the template system you use? I’m sure someone else knew what it was in another post but I can’t remember. I wonder whether whatever part of it translates
<p>{{ME balance}}</p>
into displaying that actual variable you pass in also handles formatting it, and that would explain why, whatever format you pass into it, it still comes out the same.