Re: [PHP] Formatting Percents
When you print out the value just use printf("%.2f",$bprice); Like in C On Thursday 16 August 2001 21:31, you wrote: > Hello everyone, > > I am having a problem and can't seem to find an answer. Maybe someone here > can help. I have a gift store that has prices of items. Well each item has > a retail price that I have added to the DB. Let's say I want to sell the > products at a discount of 15% but I don't want to change all the records. I > want to use PHP to configure the 15% off price. How does one do this? Does > the MySQL field need to be formatted a certain way? > > I want to show: > > Retail Price: $100.00 > Your Price: $85.00 > > Thanks in advance and let me know if you need more information. > > David Smith > Indy Web Design > 877-347-1270 or 317-573-2486 > http://www.indywebdesign.com > > -- > Visit our online gift store at http://www.123giftshopping.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Formatting Percents
On Fri, 17 Aug 2001 14:19, David Smith wrote: > What I have in code. > > If the retail price is $139.95 and I use the following: > > $aprice = $hotbuys["price"] * .15; // Determine Discount > $bprice = $hotbuys["price"] - $aprice; // Subtract Discount > > $bprice = 118.9575 > > How can I format that to just 118.96? $discount = .15; $discount_price = number_format($hotbuys["price"]*(1-$discount), 2) should do something like what you want. -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA It's smart to pick your friends, but not to pieces. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Formatting Percents
DOH, wouldn't you know it. As soon as I sent these messages I found my answer... $sellprice = round ($bprice, 2); -Original Message- From: David Smith [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 16, 2001 11:50 PM To: David Smith; [EMAIL PROTECTED] Subject: RE: [PHP] Formatting Percents What I have in code. If the retail price is $139.95 and I use the following: $aprice = $hotbuys["price"] * .15; // Determine Discount $bprice = $hotbuys["price"] - $aprice; // Subtract Discount $bprice = 118.9575 How can I format that to just 118.96? -Original Message- From: David Smith [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 16, 2001 11:31 PM To: [EMAIL PROTECTED] Subject: [PHP] Formatting Percents Importance: High Hello everyone, I am having a problem and can't seem to find an answer. Maybe someone here can help. I have a gift store that has prices of items. Well each item has a retail price that I have added to the DB. Let's say I want to sell the products at a discount of 15% but I don't want to change all the records. I want to use PHP to configure the 15% off price. How does one do this? Does the MySQL field need to be formatted a certain way? I want to show: Retail Price: $100.00 Your Price: $85.00 Thanks in advance and let me know if you need more information. David Smith Indy Web Design 877-347-1270 or 317-573-2486 http://www.indywebdesign.com -- Visit our online gift store at http://www.123giftshopping.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Formatting Percents
What I have in code. If the retail price is $139.95 and I use the following: $aprice = $hotbuys["price"] * .15; // Determine Discount $bprice = $hotbuys["price"] - $aprice; // Subtract Discount $bprice = 118.9575 How can I format that to just 118.96? -Original Message- From: David Smith [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 16, 2001 11:31 PM To: [EMAIL PROTECTED] Subject: [PHP] Formatting Percents Importance: High Hello everyone, I am having a problem and can't seem to find an answer. Maybe someone here can help. I have a gift store that has prices of items. Well each item has a retail price that I have added to the DB. Let's say I want to sell the products at a discount of 15% but I don't want to change all the records. I want to use PHP to configure the 15% off price. How does one do this? Does the MySQL field need to be formatted a certain way? I want to show: Retail Price: $100.00 Your Price: $85.00 Thanks in advance and let me know if you need more information. David Smith Indy Web Design 877-347-1270 or 317-573-2486 http://www.indywebdesign.com -- Visit our online gift store at http://www.123giftshopping.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]