Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
 Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org Math operations with PHP
 Linux - Newbie This Linux forum is for members that are new to Linux. Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

 04-20-2005, 05:13 AM #1 linuxfond Member   Registered: Jan 2003 Location: Belgium Distribution: Mandrake 9.2 Posts: 475 Rep: Math operations with PHP Hello folks, How can I tune this code to make more calculations? Say, if ' . \$_POST['sub_tot'] . ' is bigger than 200, subtract 10% from it, and print the result. If it is bigger than 300 deduct 15% and print the result. Thanks in advance.
 04-20-2005, 06:58 AM #2 linuxfond Member   Registered: Jan 2003 Location: Belgium Distribution: Mandrake 9.2 Posts: 475 Original Poster Rep: \$first = 154; \$second = 254; \$third = 354; \$subtot1 = \$_POST['sub_tot']; \$percentage_1 = 0.10; \$discount_1 = \$subtot1 * \$percentage_1 -\$subtot1; \$subtot2 = \$_POST['sub_tot']; \$percentage_2 = 0.15; \$discount_2 = \$subtot2 * \$percentage_2 -\$subtot2; THis is very clamsy, but... if (\$subtot1 >= \$first) { echo "Your discount is 10% - Total: \$discount_1"; } elseif (\$subtot2 >= \$second) { echo "Your discount is 15% - Total: \$discount_2"; } Unfortunately, the first statement is always true. If \$subtot1 is greater than 154, it always print "Your disocunt is 10% How can I tell the script

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post frankie_DJ Programming 12 10-20-2005 03:39 AM KissDaFeetOfSean Programming 1 09-12-2005 04:06 PM snorky Linux - Newbie 2 11-24-2003 07:07 PM davi_cabral Linux - Newbie 1 09-26-2003 11:04 AM dbeyes Linux - Newbie 1 04-22-2003 06:09 PM

LinuxQuestions.org

All times are GMT -5. The time now is 08:36 PM.

 Contact Us - Advertising Info - Rules - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -