Number_Format

wxdqz

New Member
How can I incorporate the number_format - to set the decimal places to 2?

I have tried using the following code for the below query:

$charge=number_format($charge=(1 + ($percent/100)),2);

But this doesn't seem to work. Currently the price being displayed is something like $####.#### which should only be $####.##

Any Ideas?

case 0:
$charge=(1 + ($percent/100));

//Set Add Percentage & Round
$query = "SELECT descr, cost*$charge as newcost, part_num, vend_code, manu_part FROM products WHERE UPPER(descr) LIKE '%$input%'";
if ($result = mysql_query ("$query")) {
while ($row = mysql_fetch_array ($result))
{
echo "<U>Product Description:</U> ".$row[descr]."<br><U>Manufactuer:</U> ".$row[vend_code]."<br><U>Manufactuer Part Number:</U> ".$row[manu_part]."<br><U>Our Part Number:</U> ".$row[part_num]."<br><U>Our Price:</U> ".$row[newcost]."<br><br>";
}
}
break;


Thanks!
 
Back
Top