Page 1 of 1

Insert multiple rows in database

Posted: 2014-11-14 12:43
by Accumike
We have a database that holds weekly employee shift information. There are up to 7 (daily) shifts for each job function.
Each employee shift is a different record - example fields: (user_id, user_name, date, start_time, end_time, header_id) etc.
Each week therefore consists of several records, grouped by a header record.

We add / delete shifts using ADDT with individual transactions, displayed with a do-while loop.
This works well as we can fine tune each shift as required. See screen grab:
Image

NB: We don't use the Nextensio dynamic multiple row forms as these conflict with other parts of the site, making it unreliable.

Now, to set up next week,we want to be able to copy all the shifts from this week to next week as one action. We can get all the shift information, using recordsets and repeat regions, but I am stuck on the multiple insert transaction.

Is it possible to do this with the Custom Form Wizard? Or how else might this be done?

We use the PHP / MySQL model.

Any help much appreciated.

Michael

Re: Insert multiple rows in database

Posted: 2014-11-15 15:36
by Fred
Micheal you probably better of doing it manually.
Create a new page and apply the usual security measures

Then use

Code: Select all

mysql_query("INSERT INTO 'target_table' (column1, column2) (SELECT (column1, column2) FROM 'source_table' WHERE something = something"));
Then redirect somewhere.

Re: Insert multiple rows in database

Posted: 2014-11-25 18:55
by Accumike
Thanks Fred, I'll have a look at this.