Share your knowledge at the LQ Wiki.
 Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org Math operations with PHP
 User Name Remember Me? Password
 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, 06: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, 07: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

 Thread Tools Search this Thread Search this Thread: Advanced Search

 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 04:39 AM KissDaFeetOfSean Programming 1 09-12-2005 05:06 PM snorky Linux - Newbie 2 11-24-2003 08:07 PM davi_cabral Linux - Newbie 1 09-26-2003 12:04 PM dbeyes Linux - Newbie 1 04-22-2003 07:09 PM

All times are GMT -5. The time now is 06:47 PM.

 Contact Us - Advertising Info - Rules - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -
 Advertisement
 My LQ
 Write for LQ LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
 Syndicate Latest Threads   LQ News Twitter: @linuxquestions Facebook: linuxquestions Google+: linuxquestions