UPDATE query with calculatons and variables.

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
synical21
Forum Contributor
Posts: 150
Joined: Tue Jul 28, 2009 8:44 am
Location: London UK

UPDATE query with calculatons and variables.

Post by synical21 »

Finally on the final stage of building my website :D But with this comes a new part to learn and im stuck on the first hurdle, i have tried to do this my self for a day but now i have run out of paitence and come here.

Basically its to do with money/intergers and users with a bit of calclation. What im trying to do is when user clicks "accept" they will be forwarded to "processing.php" Now the calculations start,

First problem how will i get the user id where the money is being sent to when its not the current user thats a big headache for me... But this is what i done so far.


$perperson = money to add

Code: Select all

 
$sql = "UPDATE users set user_money = user_money + $perperson WHERE user_id = dont know how to get id of user";
But then the $perperson is a problem in it self because $perperson value changes depending on the job_id what is used so i got another headache there.


Just need some help basically in the theory/process i need to use to get intergers added to a user
ocpaul20
Forum Newbie
Posts: 12
Joined: Thu Jul 05, 2007 3:53 am

Re: UPDATE query with calculatons and variables.

Post by ocpaul20 »

Maybe you need to post a bit more information?
If I understand this correctly, you need to pass variables from an entry form to a processing program?
Assumption -> Person A pays Person B
You need to know who Person A is (what his user_id is)
You need to know who Person B is (what his user_id is)
If you dont know who these people are, how can you update their record?

Maybe start with a design, even a simple one, and put your design down on paper as a process flow diagram. This will help in seeing where you need what information. (Person A id, Person B id, etc)

Then you will need to pass information from entry form to processing program either by GET or POST methods (or other ways such as SESSION variables too). Huge assumptions, sorry, but best I can do without more info.
synical21
Forum Contributor
Posts: 150
Joined: Tue Jul 28, 2009 8:44 am
Location: London UK

Re: UPDATE query with calculatons and variables.

Post by synical21 »

Ok here is a quick flowchart of what needs to happen:

http://a.imagehost.org/view/0324/flow

Like i said the problems im having is getting user 1's id as it always changes and the amount of money to send. The information is all in the database what i need to use i believe its just a matter of writing the php to use it all.
Post Reply