I'm creating something small for reps to follow up on sales. can somebody help me out with this the problem is $com commision on sales.
I don't think you can use SUM in values, you can only use it when selecting fields like SELECT name, SUM(totals) *sums all the rows* You are probably better off doing it manually without the SUM()
Remove the quotations from around $com to make the function run, but I'm pretty sure it's not SUM you need! Good luck Dan
hmm, i havent really tried this before, is an aggregate function like SUM possible to use during inserts? based on the query there's not even anything to SUM... damn, i just got dizzy
I'm pretty sure of it myself. all functions are working when I remove $com completely I just thought i'll make things a little easier for them. They can calculate their own commissions. The lazy buggers, sit around all day drinking coffe and work on my nerves. thatwill keep them busy.
The SUM() function is for use within MySQL SELECT statements to aggregate a column. Furthermore, if you wished to use the function within the query you should have placed it within a string because SUM() is not a function within PHP:- $com = 'SUM(' . $amount * 0.25 . ')'; PHP: You can calculate the commision by removing the SUM() function:- $com = $amount * 0.25; PHP:
thanks, I had this 'SUM' thing of exel in my head. clearly its not the same thing. Anybody who ever worked with exel will understand what I mean. this is how I learn
I don't think anyone is laughing at you... and plus this is a php forum to help so we expect any kind of questions too, be it basic or advanced... it's all about learning
dude, i'm not laughing at you, were actually both learning, i just havent tried this query before so i got a little confused. anyways i apologize if that post somehow offended you, i did not mean it that way -cheers
I'm sitting here laughing at my own stupidity while i'm reading up about what SUM() does. I was way off. lol
no problem buddy, I'm an old man trying to learn new stuff, I don't take offence easily.. lets all laugh together and have a jolly time.
Thanx Clarky that worked John will earn $32k commision July Mary will earn $26k I pay them tooo damn much
This works, I just wonder why the "PRO's" couldn't tell me this from the start. Just kidding. Thanks guys $com = $amount * 0.25; $qry = "INSERT INTO data (date, rep, client, amount, com, status) VALUES ('$postdate', '$rep', '$client', '$amount', '$com', 'pending')"; $result = mysql_query($qry); if($result) { header("location: success.php"); exit(); }else { die("Query failed"); } PHP: