Jump to content

Question about number formatting


aeroswat

Recommended Posts

Here's my code. For some reason it formats any number that is 1000 or over as 1.00

 

$val = 1018;
		if(is_numeric($val)) {
			$val = number_format($val,2);
			mysql_query("UPDATE " . ($_SESSION['SESS_DB_YEAR'] == 0 ? 'tblOrders' : 'tblOldOrders' . $_SESSION['SESS_DB_YEAR']) . " SET Cost='" . $val . "' WHERE OrderNumber='" . $order . "'");
			echo '1';
			$_SESSION['MultiOrderRes'][$pos]['Cost'] = $val;
		} else{
			echo '0';
		}

 

All I want for it to do is format all numbers with 2 decimal places. Can anyone illuminate why its doing this?

 

EDIT: Also the field its storing in the database is decimal(10,2)

Link to comment
https://forums.phpfreaks.com/topic/203681-question-about-number-formatting/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.