V
V
vadimstroganov2015-03-04 00:43:40
MySQL
vadimstroganov, 2015-03-04 00:43:40

How to make a connection in the database?

Good evening.
I can't figure out the relationships in the database.
There is table_1(id,name) and table_2(user_id, param_1,param_2)
I can’t figure out how to do the following: when adding a person to table_1, at that moment a record was created in table_2, and such that user_id = id (from table_1) and created param_1,param_2 for this user_id.
Tell me how to implement this, or direct - in which direction to look?)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir, 2015-03-04
@rostel

hang a trigger on INSERT in table_1

V
Vladimir Golub, 2015-03-04
@RazerVG

$query = mysql_query("INSERT INTO orders_in_shop (id_client, price_order, status, data_order) VALUES ('$id_client','$price','$status', '$data')");
$id_order_in_shop = mysql_insert_id();

For example, you will have an added id in the variable and add it to the required table with the next queries.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question