This topic is locked
[SOLVED]

 Inserting Master Table Data Into Details Table

12/30/2011 3:55:46 PM
PHPRunner General questions
C
copper21 author

Happy New Year to all,
Have searched the forum up and down, left, right, and even did A, B, Select, Start....Anyway I am having problems getting data from the master table into the details table. I have a master table called "events_main_event" which has the fields: eventid, event_title, event_type, event_date, time_frame1, and time_frame2. I have a details table called "events_staff_signup" that has the fields: staffid, staff_event_link, event_title, event_type, event_date, time_frame1, and time_frame2, and a few more. The details table is linked to the master table via staff_event_link.
What I am looking to do is when the user clicks on the details link on the Master List Page, they can do an In-Line Add of a details record...very simple and that works great. What I want to do is autofill the fields: event_title, event_type, event_date, time_frame1, and time_frame2 into the child record from the master record. I am NOT using an ADD page at all for this, I am just using the In-Line Add of the Child Record from the Master List Page.
So what happens is an event is added to the "events_main_event" master table. After the record is added to the master table, a staff memeber can signup for the event by clicking on the details link on the list page of the master table using the In-Line Add feature. When the staff member clicks the link and clicks "Inline Add" the form is then pre-populated with some of the data from the master table and then the staff member fills out the rest of the blank fields on the form.
I am using PHP Runner 6.0 Build 9948 with a SQL database.
EVENTS_MAIN_EVENT

eventid,

event_title,

event_type,

event_date,

time_frame1

time_frame2,

......
EVENTS_STAFF_SIGNUP

eventid,

staff_event_link,

event_title,

event_type,

event_date,

time_frame1,

time_frame2'

......
Thanks in advance for any help!
Brian

C
cgphp 12/30/2011

Go to the events tab. In the "Process record values" event of Add page of the EVENTS_STAFF_SIGNUP table, enter the following code:

$rs = CustomQuery("SELECT event_title, event_type, event_date, time_frame1, time_frame2 FROM EVENTS_MAIN_EVENT WHERE eventid=".$_GET['masterkey1']);

$record = db_fetch_array($rs);

$values['event_title'] = $record['event_title'];

$values['event_type'] = $record['event_type'];

$values['event_date'] = $record['event_date'];

$values['time_frame1'] = $record['time_frame1'];

$values['time_frame2'] = $record['time_frame2'];
C
copper21 author 1/2/2012

Cristian,
Thanks for the help! The data shows in the field and gets inserted into the database just like I want it too; however I get an error when the record is added.
Error Type 256

Error Descrption: Source: Microsoft OLE DB Provider for SQL Server Description: Incorrect syntax near '='

URL: SERVER/events/events_staff_signup_add.php?ferro=1&inline=1&

Error File: dbconnection.mssql.win.php

Error Line: 42

SQL Query: SELECT event_title, event_type, event_date, time_frame1, time_frame2 FROM events_main_event WHERE eventid=
Thanks again for any assistance.