Ravi Ravi - 2 years ago 137
SQL Question

HTML Not showing decimals from mysql db in Laravel Blade

In my mysql db I manage table's column to keep product prices.like $200.00 or $200.50 (only two points). When it comes to html I catch it like this from blade view.

<p class="excerpt col-md-6 col-md-offset-5 alert alert-danger">Price per Instance : AUD ${{$product->product_price}}</p>

Problem is, $200.00 it is not showing .00 and when $200.50 it is 200.5 and $200.51 or any two point it gives $200.50999450684 something like this. What should I do

And also please let me know how to save number with two decimal point in html to mysql db


Update 01:
my table structure

enter image description here

Answer Source

Make sure to set your produce price column in MySQL to DECIMAL(5,2) for prices between $0 to $999.99. If it's not, run


replacing #PRODUCTTABLENAME with your table's name and #PRODUCTPRICECOLUMNNAME with your column's name

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download