Jump to content

how to insert into join table


hardikspider123

Recommended Posts

Hi I want to create an application.

 

Main form contain other form(one to many relationship) 

for example if I insert record for one employee which can have multiple phone numbers.so I should be able to insert multiple phone numbers for one employee.

 

so can you give me hint that how should I create this scenario. I have developed form already but don't know from where  start coding. 

 

I am new to php,jquery,ajax,html

 

Please guide me.

 

Thanks in advance.

Link to comment
Share on other sites

 

Main form contain other form(one to many relationship)

 

You can't nest forms. Your data tables will be 1 to many though, an employee table and a phone table, each row of which contains employee id and a phone number.

 

Just have one form containing employee fields and multiple fields for phone number entry.

 

Name the phone fields something like "phone[]" so they are posted in an array, which you can loop through to process.

 

When processing, insert the employee data and grab the last_insert_id to get the value of the new auto_incremented id field. Use this to insert the emp id value in each of the phone number records.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.