Jump to content

inserting into 2 tables, table 2 with multiple records


rajchahal

Recommended Posts

hi there

 

I have a whats on section, table 1 holds event info, name, location etc

The 2nd table holds occurances of events, these are date pairs, publish-date and unpublish-date.

 

On the admin page I would need to to insert items into table 1 and items into table2, but with table 2 I may have more than one occurance (record) to add. As I could have 2 sets of dates an event occurs on.

 

I need only ONE button that would update both tables.

 

Also, to make this a bit user friendly, with table 2 I would like to have a + / - buttons So I can either add another date pair or remove a date pair.

 

Could someone explain how i can do this.. Code would be great !

 

Thanks

Just relate your second table, even_occurrences, to your event_info table.

 

event_info

ID | EventInfo | Location

1    Event!11    Your backyard

 

event_occurrences

ID | EventID | PublishDate | UnpublishDate

1    1            Date1            asdf

2    1            Date2            asdf

Thanks for your reply

My tables are already related, table 2 uses a foreign key that matches table1.

But this is not what I meant,

I want to have a page with data from two taples displayed on it, then I can update the fields, finally I want to press a single button to update both tables.

The added complication is that I would like to add more than 1 occurance to table2.

See attached image pls

 

 

[attachment deleted by admin]

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.