Mauricio Ramirez Mendoza February 2016

Number Format with PHP to MySQL stored data

I have a problem with my inventory page (Im a nooby in PHP) I have uploaded all my inventory items but the price column in MySQL its a VARCHAR 255 I want to format with php all the data in the price column to number format I want this>> 10000 look like this>> 10,000

I actually have my code like this

 <div class='wrap'><b>Price</b><br>
     <div class='price'>$ $row[8]<br>
  </div>

Answers


Alejandro Iván February 2016

Maybe...?

<div class="wrap"><b>Price</b></div>
    <div class="price">$ <?php echo number_format( $row[8] ); ?></div>
    <br />
</div>

If you're echoing it, probably...

<?php
$formatted = number_format( $row[8] );
echo "<div class=\"wrap\"><b>Price</b></div>
        <div class=\"price\">$ {$formatted}</div>
        <br />
      </div>";
?>

Post Status

Asked in February 2016
Viewed 3,165 times
Voted 4
Answered 1 times

Search




Leave an answer