RE: [PHP] Limiting number of decimal places reported
John, Try using the number_format function. Bev -Original Message- From: John Wulff [mailto:[EMAIL PROTECTED]] Sent: Saturday, June 29, 2002 3:10 PM To: [EMAIL PROTECTED] Subject: [PHP] Limiting number of decimal places reported How do I limit the number of decimal places returned in this query? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Limiting number of decimal places reported
> How do I limit the number of decimal places returned in this query? > > > $result2 = mysql_query("SELECT sum(purchase_price) as total FROM assets > where order_number='$order_number'"); > > while(list($order_total) = mysql_fetch_row($result2)) > > { > > print ("$order_total"); If you were using the correct column type in MySQL, DECIMAL, you shouldn't have to worry about the decimal places. Otherwise, you can use number_format() on $order_total. Also, the while() loop isn't needed, since only one row is returned from a query like that without a GROUP BY clause. Also, you don't need the quotes around $order_total when printing it out. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Limiting number of decimal places reported
round($order_total), floor("), ceil(") are some options. > How do I limit the number of decimal places returned in this query? > > > $result2 = mysql_query("SELECT sum(purchase_price) as total FROM assets > where order_number='$order_number'"); > > while(list($order_total) = mysql_fetch_row($result2)) > > { > > print ("$order_total"); > > } > > ?> > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -Pushkar S. Pradhan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Limiting number of decimal places reported
How do I limit the number of decimal places returned in this query? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php