Skip to content
Advertisement

Insert data in a different table sql/ php

Could you please help me i have two different tables

table tbl_users:

JavaScript

table travail:

JavaScript

I put idjob as a foreign key .*

And I want to insert the value of job in the user table and i don’ know how

the following code of “job” section

register.php:

JavaScript

Users.php:

JavaScript

Advertisement

Answer

In your register.php, it would be way more practical to have the ids of the jobs as values instead of having the names of the jobs. Then you can just plug that number in the insert just like you’re plugging in name and everything else. You can surround your input with labels instead of putting the names of the jobs in the value, like this:

JavaScript

Then you do the validation of the field on the php side, like you’re doing to all other fields and add it to the query. The FK is just a regular field.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement