Vote Up 0 Vote Down

php - How to display information to the user from another table?

I'm writing a personal account with the conclusion of the table, which takes the data from the database. Each user will issue a login and password, after the user has logged in, the table comes with its data.

As I realized: I created a table "users", in which there were fields:

 id_user login_user pass_user name_user data_user summa_user credit_user dolg_us staus_us monthly_us 

Showed a more experienced developer, but he is very busy person, so ask for help from you. He told me to do so: create 2 tables, the first will be information about the user, that is:

users: id_user login_user pass_user name_user 2 таблица credit: id_credit data_credit summa_credit credit_credit dolg_credit staus_credit monthly_credit 

Until that moment, I realized, and then I have questions:

How then display each user their own data? That is, if I create a second table and fill it, then all users will be displayed one information, and I need to have each user had their own information, that is, id. If the first user id 2 (because the admin id-1), it is necessary that the information he had his own, with the second table credit, id 1.


Vote Up 0 Vote Down
You should add to the table one more option "user_id", which will assign a value from the table users, and then when you need to pull up the value of the credit for the users, you can do it.


And then

SELECT * FROM credit WHERE user_id = 1;
flag | link |

Your Answer

Login before answering

Login with facebook