My payment pages's thank you page (the attached [url removed, login to view]) currently sends an email to all our associates when a new sale has been made.
I want the [url removed, login to view] page to make a mysql query to my database's table to figure out exactly which associate made the sale.
If we find a perfect match of the sales' email address in my database then:
If only one match is found then that associate gets a particular email (similar to the one in lines 47-86)
Else if more than one match is found, the matching associates receive a special email
Else (if email address not found at all in database) then the current email is still used.
I've attached my main payment page in case you need to see it([url removed, login to view]) which creates a txt file based on ip address.
Lastly, I need the exact same mysql query and if/else statements creates above placed properly in [url removed, login to view], which processes incomplete sales by sending us/the appropriate associate an email message.