This topic is locked
[SOLVED]

 format value while php

1/2/2020 10:20:36 AM
PHPRunner General questions
L
luchoadmin author

Hi

I am putting together a table and I want to change the format in view of the query.

in this way the kilograms appear to me thus 701.9999999999999 Kg.

and I would like them to appear with the format 2, '.', ''

That would be 701.99 kg but I don't know how to do it. I leave the table example
echo "<table class='table'>";

echo "<tr>";

echo "<th>CANTIDAD DE PESADAS</th>";

echo "<th>TOTAL DE KILOGRAMOS</th>";

echo "</tr>";
while ($columna1 = mysqli_fetch_array( $resultado1 ))

{

echo "<tr>";

echo "<td><h4><b>".$columna1['total1']."&nbsp;</h4></td>";

$numero1=$columna1['total1'];
}

while ($columna = mysqli_fetch_array( $resultado ))

{
echo "<td><h4><b>".$columna['total']."&nbsp;Kg.</h4></td>";

$numero=$columna['total'];

echo "</tr>";

}
echo "</table>";

N
Nir Frumer 1/2/2020

hi

use the php number_format() function in

Fields -> view as , choose CUSTOM and define your format
another way would be, defining your field's 'view as' number with the desired number of decimals
the 1st is more flexible, the 2nd would respect localization configuration..
hope it helps,

Nir.

S
Steve Seymour 1/2/2020



hi

use the php number_format() function in

Fields -> view as , choose CUSTOM and define your format
another way would be, defining your field's 'view as' number with the desired number of decimals
the 1st is more flexible, the 2nd would respect localization configuration..
hope it helps,

Nir.


https://www.php.net/manual/en/function.number-format.php

L
luchoadmin author 1/2/2020