Jump to content

upload to multiple tables


gavenf

Recommended Posts

I want to create a form that will upload information into a db but I am not sure if I need to use multiple tables.

 

The information is pretty basic really but there will be alot of info to upload, all of which needs to be linked.

 

The general company info is

Name

Address

Suburb

State

Country

Postcode

Phone

Fax

..and other fileds

 

Linked to this will be another form that allows them to upload position information such as

 

positio title

description

hrs of work

responsibilities

...etc

 

How do I link this information so that once they have uploaded the company information they move on to upload position information.  They may have multiple positions that need to be uploaded and may choose to do it at different times.

 

Thanks

 

Gaven

Link to comment
https://forums.phpfreaks.com/topic/53257-upload-to-multiple-tables/
Share on other sites

I think you're asking two questions:

 

(1) how to display the form data so the user workflow is correct, and

(2) how to structure the DB appropriately.

 

To answer (2), if you have a one-to-many relationship, i.e. one company may offer more than one position, then you need separate tables, COMPANY and POSITION, linked by either a foreign key (not available in phpmyadmin), or just an index. So, e.g. the POSITION table has a column called COMPANY_ID which links up with COMPANY_ID in COMPANY table. These should be unique. When you write to the POSITION table, you don't need to repeat all the company data, you just include COMPANY_ID for reference.

 

For question (1), you can just write an IF statement in PHP that shows the first form, and when that has been submitted, displays the second form. Is that what you mean?

 

So the "ADD COMPANY/POSITION page" on first request will go something like:

 

FILL IN COMPANY DETAILS (form1) - OR - CHOOSE COMPANY FROM DROPDOWN (form2)

FILL IN POSITION DETAILS (form3)

 

So, if neither form1 nor form2 submitted, show form1 and form2 but not form3, else show form3.

 

if (!POST[form1] && !POST[form2]) {

    echo (form3 stuff)

} else {

    echo (form 1 and form2 stuff)

 

hope this helps

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.