How to update a different table with a data from another table in PDO

0

Personal I have a payroll table, and I have an indemnification code for each transaction, when receiving the data of the update, I want to get the data and insert in update in another table of the bank being that 1 of the fields does not have in the other table that is

In the table that I will update, has user and value, but n has the code, and to define if really and that user is going to receive the code and not duplicate, I need to be specific of that code ... someone could me to help? example:

USER 1 bought 30 reais, xx3 purchase code

When the purchase is approved, will receive from the purchase code xx3 the return of purchase and release of these 30 reais of credit, and will insert in the table (the 30 reais) of credit.

    
asked by anonymous 26.06.2017 / 20:46

1 answer

1

That sounds simple.

1) There are 2 tables. One has user, value. In the other there is user, value and code.

2) Insert the 'code' column in the first table, so the two are the same, you can easily insert this column by a simple SQL command or by phpmyadmin.

3) Now, just take the value of a table, through PHP and insert in the other. You should do this with PHP (variables) and a simple SQL (update) command.

4) Use the PDO to connect and manage your database with PHP.

NOTE: Show your code attempts so we can help you better.

Until.

    
27.06.2017 / 01:08