I have been working on PHP for quite sometime but recently I have been faced with a situation in which I have to create a MASTER DETAIL form having CRUD operations [Create, Read, Update and Delete]. In PHP, i have never done this and looking for some sample code in order to achieve this.
Let me give an example what I want to achieve:
Master Information: [Voucher_Master]
===============
Transaction Number:
Voucher Date:
Voucher Description:
Detail Information: [Voucher_Detail]
==============
Account Code Account Name Debit Credit
There is one to many relationship between Voucher_Master and Voucher_Detail.
I would be very thankful if somebody can guide me in this regard.
Eagerly waiting for response.
Creating Master-Detail or Parent-Child Form in PHP
Moderator: General Moderators
-
rehanqadri
- Forum Newbie
- Posts: 2
- Joined: Fri Jul 31, 2009 11:21 am
-
DaiLaughing
- Forum Commoner
- Posts: 76
- Joined: Thu Jul 16, 2009 8:03 am
Re: Creating Master-Detail or Parent-Child Form in PHP
Bear in mind I'm only answering this because no one else has!
Personally I have done this a couple of years ago using just one form. The one side of the relationship is populated with a query. Then the many fields of the form are populated with a loop using data from another query. The way I handled the repeated data was just to rename the fields with the primary key after the field name. So you would end up with Detail_Information1, Detail_Information2 o whatever the fields were. When the form was posted I then stripped the ID back off of the end of the field name and saved the data in the related "many" table.
Ugly but it worked. I believe the correct way would be to create the form with a loop as I did but give the fields in the repeated area a single name but with square brackets after the name. Then the repeated fields would be stored in $_POST but in their own array. Then you can more easily FOREACH through the results. I have never goteen around to trying it on a proper page but it should work better than my kludge.
Personally I have done this a couple of years ago using just one form. The one side of the relationship is populated with a query. Then the many fields of the form are populated with a loop using data from another query. The way I handled the repeated data was just to rename the fields with the primary key after the field name. So you would end up with Detail_Information1, Detail_Information2 o whatever the fields were. When the form was posted I then stripped the ID back off of the end of the field name and saved the data in the related "many" table.
Ugly but it worked. I believe the correct way would be to create the form with a loop as I did but give the fields in the repeated area a single name but with square brackets after the name. Then the repeated fields would be stored in $_POST but in their own array. Then you can more easily FOREACH through the results. I have never goteen around to trying it on a proper page but it should work better than my kludge.
-
rehanqadri
- Forum Newbie
- Posts: 2
- Joined: Fri Jul 31, 2009 11:21 am
Re: Creating Master-Detail or Parent-Child Form in PHP
thanks mate, i will surely try it out and will late you know about the progress and issues.
thanks again
thanks again