Apply comma to numbers in td of table

Issue

I have a list of numbers in a table resulting from mySQL:

How do I apply the comma to the number fields: “min” and “max”

$query = "SELECT min, max, qty FROM cartons_current LIMIT 0,50";
$result = $db->query($query, MYSQLI_STORE_RESULT);
$o = '<table><thead><tr><th>Min</th><th>Max</th><th>Qty</th></tr></thead><tbody>';
while(list($min, $max, $qty) = $result->fetch_row()) {

$o .= '<tr><td>'.$min.'</td><td>'.$max.'</td><td>'.$qty.'</td></tr>';}
$o .= '</tbody></table>';
echo $o;
?>

Solution

You probably want to use number_format().

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

Answered By – Sam Dufel

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published