I have a MySQL query that fetches a numeric value VARCHAR (20) from a table, and I need to format the result to include thousands separators (,) and decimal separators (.) to two positions.
I’ve searched a lot for a simple query, so now I want to know if this is possible using CSS.
Here is the table data:
Income ------------------- 1234456789 234456000 987456000
And so on. Here’s the query:
// Fetch data
$sql="SELECT * FROM scoreboard WHERE codcliente = '".$q."' OR nombre LIKE '%".$q."%'";
$result = mysql_query($sql);
if(mysql_num_rows($result) == 0){
echo '<div align="center" style="background-color:#CCCCCC; font-weight:bold; color:#C0504D;">Record no existe. <input id="srchcreate" type="button" value="Crear" /></div>';
return;
}
//echo $result;
And the result:
// Construct the table
echo "<table>";
// Construct the array
while($row = mysql_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['codcliente'] . "</td>";
echo "<td>" . $row['nombre'] . "</td>";
// echo "<td>" . $row['ejecutivo'] . "</td>";
// echo "<td>" . $row['banca_as400'] . "</td>";
// echo "<td>" . $row['banca_real'] . "</td>";
// echo "<td>" . $row['ingresos'] . "</td>";
echo "<td>" . $row['ciiu'] . "</td>";
// echo "<td>" . $row['division'] . "</td>";
echo "<td>" . $row['actividad'] . "</td>";
echo "<td>" . $row['riesgo_industria'] . "</td>";
echo "<td>" . $row['riesgo_cliente'] . "</td>";
echo "<td>" . $row['fecha'] . "</td>";
echo "<td>" . $row['analista'] . "</td>";
echo "</tr>";
}
echo "</table>";
This gets inserted to a PHP file and displayed as a table.
123,456,789.00