Apply comma to numbers in td of table


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;


You probably want to use number_format().

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