This topic is locked

insert Record into another Table

3/16/2006 12:52:31 PM
PHPRunner General questions
B
BluePhoenixNC author

<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=2630&image=1&table=forumtopics' class='bbc_emoticon' alt=':unsure:' /> Ok, I read throught the forum but some things are still unclear to me.

Here is my situation:

2 tables (Payment_CC, Payments) Payment_CC has the fields (Date,Account_number,CC_Number, CC_Exp_Mo, CC_Exp_Yr, Name_on_Card, CC_type, CC_Amount, etc) Payments has the fields (Date, Account_Number, Amount)

Both Tables are Detail Pages of a 3rd table linkd via the Account_Number.

What I am trying to accomplish is: after entering data into Payment_CC, I want that the table 'Payments' recieves the values (Date, CC_Amount, Account_Number) from Payment_CC into the Fields (Date, Account_Number, Amount).

How do I do that ? I was looking into an After update Event, but in the forum everything points to a before AND After Event. Now I am confused. Any help in this direction is greatly appreciated.
Thank you very much


The more I read through the forum the more confused I get. I am in serious need of some guidance, here. Please note I am a newbie when it comes to PHP and MySQL. I have done the following changes (and I am not even sure if this is the way to do it) Master-Table: "Customer" <- This table just holds Account_Number, and contact information; Child Table: "Payments" <- linked to Master-Table with the field "Account_Number" that table is supposed to just hold payments (amounts and dates).

Then Payments is the Master-Table for 2 other Tables, one would be Payment_CC also linked together with the Field "Account_Number". CC_Payments holds the Credit_Card Information, including the date payment was made and amount.

Now I encounter 2 problems: a) I do not see the child table(s) once I am in child (Payments)

<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=2630&image=2&table=forumtopics' class='bbc_emoticon' alt='B)' /> I want that when I enter Data into CC_Payments that the Data (Date, Amount) are written into the Payments Table.

Am I making it to complicated ? Any suggestion and Ideas are greatly appreciated. Perhaps one of you Database Gurus can show me the way.
Thank you.

Sergey Kornilov admin 3/17/2006

Hi,

  1. master-detail relationship work correctly. Please ensure that you settings are right.

    Otherwise please zip and send to [email=support@xlinesoft.com]support@xlinesoft.com[/email] a full set of generated PHP files, your database creation script with sample data.

    I'll find what's wrong with your project running it on my test box.
  2. you can do it using Before record added event for CC_Payments table.

    See my example below:
    function BeforeAdd(&$values)

    {

    global $conn;

    $strSQLInsert = "insert into Payments (Date, Amount) values (".$values["Date"].",".$values["CC_Amount"].")";

    db_exec($strSQLInsert,$conn);

    return true;

    }

B
BluePhoenixNC author 3/17/2006

Hi,


  1. master-detail relationship work correctly. Please ensure that you settings are right.

    Otherwise please zip and send to [email=support@xlinesoft.com]support@xlinesoft.com[/email] a full set of generated PHP files, your database creation script with sample data.

    I'll find what's wrong with your project running it on my test box.
  2. you can do it using Before record added event for CC_Payments table.

    See my example below:



<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=8629&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' /> Thank you so much, that works just like a charm. I am just 2 steps away from buying that awesome program, it does pretty much everything I need it to do.

One question however remains: and that is a design /customization/ layout question: Is there an easier way to completely customize the layout of the generated files, without going through each and every one ? Example: in my case it will show on the table "Payments" next to every entry a link to the CC_Payments Table, I need this link only once on the payments view. -- I believe it is somewhere in the Template Section, but I can't seem to find the part that makes it... (I also would like to have those links show up, even though the customer has not yet made a payment, so I have the option to enter it. -- I found out, that if the payments table has no entries (because they will come from the CC_Payments) that the link to CC_Payments does not even appear. -- this however does not break my head, since I could make a default entry upon creating the customer -- .

I am very happy with the support I have received here and the Program, it's A++ quality.

Thank you.

Sergey Kornilov admin 3/20/2006

This kind of help we provide to our customers only. After you purchase PHPRunner contact me directly at support@xlinesoft.com. Also I'll need to see generated files and database structure.