This topic is locked

Adding New Multiple Records - One Page

2/27/2012 4:40:24 PM
PHPRunner General questions
Z
zephyr325 author

Hello. I'm trying to create a page that would essentially be an attendance sheet that someone can fill out for a recurring event. I'm visualizing trying to have a drop down list at the top of the page with possible events and a page of open boxes (i.e., 40 of them) that could be used to enter in attendee names. I'll already have another table populated with possible attendees, so I'd like to use the AJAX lookup function available in input fields to keep the names sanitized. Once all the names have been entered, the person filling in the data would click one button and a new record would be added to a table for each of the names entered into one of the boxes.
Is the multiple input boxes on one page type of function possible with PHP Runner?
Thanks!

C
cgphp 2/28/2012

Yes, it should be possibile. We could tell you more if you give us more info about your tables structure.

Z
zephyr325 author 2/28/2012



Yes, it should be possibile. We could tell you more if you give us more info about your tables structure.



Sorry - here's more information...
I'm trying to keep tables and structures pretty simple:

  • One table ("Calendar") has one row per event - UniqueID, date, name of the event, location, etc. Updates to this table are using the standard "add a record" method.
  • One table ("Participants") has one row per person - UniqueID, PersonName
  • The attendance table ("Attendance") is also very simple - Unique ID, EventID and ParticipantName. EventID would be a link back to Calendar.UniqueID. ParticipantName would be validated by Participants.PersonName.
    It is the participants table that I want to update via the multiple fields on the same page. There would be a drop-down box from the calendar page to select the event at the top of the page. Names would be validated based off the participants.PersonName field.
    Make sense?

L
lummis 3/1/2012

I don't wish to hijack this thread but I am looking to resolve a similar problem!
My tables reflect yours but I was looking at a slightly different design. At the moment - using your table names - I can use the add page in 'Attendance' to pull the details from the 'Calendar' tables for a specific event then record each participant but if you have 30 participants this means carrying out the add operation 30 times. I was wondering if there was a way, perhaps by using check boxes, of producing a list of all likely participants which you can then tick on one page and submit as a single form.
My project involves selecting a team from a list of approx 80 names and I am trying to find a simple solution.
Brian

kujox 3/3/2012



I don't wish to hijack this thread but I am looking to resolve a similar problem!
My tables reflect yours but I was looking at a slightly different design. At the moment - using your table names - I can use the add page in 'Attendance' to pull the details from the 'Calendar' tables for a specific event then record each participant but if you have 30 participants this means carrying out the add operation 30 times. I was wondering if there was a way, perhaps by using check boxes, of producing a list of all likely participants which you can then tick on one page and submit as a single form.
My project involves selecting a team from a list of approx 80 names and I am trying to find a simple solution.
Brian


On a general note why not add into the events section addpage/before record added,
then use some mysql to insert a record in the second table using some of the same data.

$strSQLSave = "INSERT INTO AnotherTable (Field1, Field2) values (";
$strSQLSave .= $values["Field1"].",";

$strSQLSave .= $values["Field2"];
$strSQLSave .= ")";

db_exec($strSQLSave,$conn);
L
lummis 3/4/2012



On a general note why not add into the events section addpage/before record added,
then use some mysql to insert a record in the second table using some of the same data.

$strSQLSave = "INSERT INTO AnotherTable (Field1, Field2) values (";
$strSQLSave .= $values["Field1"].",";

$strSQLSave .= $values["Field2"];
$strSQLSave .= ")";

db_exec($strSQLSave,$conn);



Thanks for you response. I may have misunderstood, but I think that all this will do is to write the data added to a new table. If I have to make say 16 selections from my pool of 80 people this will still mean that I have to use the add page 16 times whereas I am looking to select all 16 at the same time and then add with a single click (possibly to a new table)
Brian

kujox 3/6/2012



Thanks for you response. I may have misunderstood, but I think that all this will do is to write the data added to a new table. If I have to make say 16 selections from my pool of 80 people this will still mean that I have to use the add page 16 times whereas I am looking to select all 16 at the same time and then add with a single click (possibly to a new table)
Brian


You can do this on the visual editor, if you click on the insert code icon then insert button from the menu. If you follow the demo bit as below you should get the idea how to get the record keys which are placed into $params.
How to update Multiple records
Once you have them you can use a Mysql insert statement to update the second table with the records.



$sql = "INSERT INTO table2 (id, details) VALUES (SELECT id,details FROM table1 WHERE id IN (".implode(',',$params)."))";
L
lummis 3/6/2012



You can do this on the visual editor, if you click on the insert code icon then insert button from the menu. If you follow the demo bit as below you should get the idea how to get the record keys which are placed into $params.
How to update Multiple records
Once you have them you can use a Mysql insert statement to update the second table with the records.



$sql = "INSERT INTO table2 (id, details) VALUES (SELECT id,details FROM table1 WHERE id IN (".implode(',',$params)."))";



Thanks Kujox - I must have missed this in the manual although I did think that it must be a regular requirement for many people. I believe that it will solve my problem but I will leave the post open as I am not sure if the original poster has the answer that they need.
Brian