I found this on teh net, but it didn't work:
Any thoughts?SELECT replace(rtrim(replace(replace(rtrim(replace(field,'0',' '))
,' ','0'),'.',' ')),' ','.') from table
Moderator: General Moderators
Any thoughts?SELECT replace(rtrim(replace(replace(rtrim(replace(field,'0',' '))
,' ','0'),'.',' ')),' ','.') from table
does work. I just need to add a field alias, like so:replace(rtrim(replace(replace(rtrim(replace(field,'0',' ')),' ','0'),'.',' ')),' ','.') FROM table
so my mysql_fetch_array pick up the value by name.replace(rtrim(replace(replace(rtrim(replace(field,'0',' ')),' ','0'),'.',' ')),' ','.') AS field
Code: Select all
$lastentryquery = "SELECT replace(rtrim(replace(replace(rtrim(replace(field,'0',' ')),' ','0'),'.',' ')),' ','.') AS fieldFROM table WHERE enteredby = $enteredby ORDER BY entrydt DESC LIMIT 1";
$userresult = mysql_query($lastentryquery);
while($row = mysql_fetch_array($userresult)){
$fielddisplay = $row['field'];Code: Select all
echo round(150.000, 1); // prints 150
echo round(169.450, 1); // prints 169.5
echo round(20.340, 1); // prints 20.3
Code: Select all
echo round(field, 1);