Mathematical Formula with PHP?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pfousek
Forum Newbie
Posts: 3
Joined: Wed Aug 13, 2008 6:39 am

Mathematical Formula with PHP?

Post by pfousek »

Hi there,

I am new to this forum, and not even sure if this is the right place to ask this question. However, this is the situation....

I am helping a friend develop a payroll form on her website. She would prefer to have the form automated so that when her subcontractors fill in the hours they work for a client the total amount gets emailed to the payroll admin automatically upon the form submit.

For example the form looks something like this:

Employee #1: Week ending 8/8/08
Client A 8 hours
Client B 3 hours
Client C 2 hours

When the subcontractor hits submit - the payroll department is emailed:

Employee #1: Week ending 8/8/08
Client A $200
Client B $75
Client C $50

Is there a php code that can this? I apologize if this is a silly question. I'm not a developer.

Thanks.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Mathematical Formula with PHP?

Post by jayshields »

If I understand you correctly, yes, that's pretty basic in PHP. It's not a very complex mathematical forumla - it's just a user submitted value multiplied by 25!

If you're looking for someone to do this for you you'd be better off posting in the Job Hunt forum.
pfousek
Forum Newbie
Posts: 3
Joined: Wed Aug 13, 2008 6:39 am

Re: Mathematical Formula with PHP?

Post by pfousek »

Can you do the same with percentages too?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Mathematical Formula with PHP?

Post by onion2k »

Anything that can be done in maths can be done in PHP.

However, the difficulty with what you're outlining here won't be the maths. It'll be figuring out a way of coding the application in a way that's both flexible and reliable. For a start, don't rely on email. Back up all the entries into a database along with the rate that they were charged at. That way if ever there's a problem with the payroll email account you won't lose any information. You'll also want a table of all the clients along with the rate they're charged, and a table with the rate the subcontractors are charged out at. You'll use those to calculate the value in the email. You'll need both figures because at some point in the future there'll be a client who pays a different rate to the others, and there'll be a subcontractor who is paid a different amount too. Lastly, you'll want to create a system that lets people securely view the previous entries and update the rates.

You might want to think about employing someone to write this. For an experienced developer it's easy. For someone who knows no PHP at all it's going to be a lot of very hard work.
pfousek
Forum Newbie
Posts: 3
Joined: Wed Aug 13, 2008 6:39 am

Re: Mathematical Formula with PHP?

Post by pfousek »

Thank you for the advice. This is very helpful.
Post Reply