Re: ARRAY, IF & INSERT

From: Date: Fri, 21 Jun 2002 09:56:06 +0000
Subject: Re: ARRAY, IF & INSERT
References: 1  Groups: php.db php.general 
Request: Send a blank email to php-db+get-19942@lists.php.net to get a copy of this message
(i am new to these groups, but shouldn't there be a follow-up-to on a X-post?) César aracena wrote:
I have this form in which one Administrator can insert new members and after that, in another page, a form where he/she can insert the new member’s sons & daughters. I want to display a table with “text inserts” into the admin can type let’s say a maximum of 5 kids in the second page.
The number doesn't matter if you design you db well (I suppose we are talking database). I suppose that you have a table with members with unique ID's? Make a new table with relatives, where you connect to their parents through a ParentID-field This way you'll avoid empty fields for the folks with eg. only 2 sons :-) The query for father + sons and daughters would then be like mysql_query(" select members.Name, members.ID, relatives.Name as RelativeName, relatives.ID from parents, relatives where parents.ID = relatives.ParentID ") The “members” table will have one memberID field (which will be
shared between parents and kids) and a levelID which will grant 0 for the parent and 1, 2, 3, 4, 5 for the kids.
You _can_ put them all in the same table, but I suppose that you have a lot of data stored on the parents/members, that is non-existing and irellevant for the children - this will give a lot of empty fields, which is why i propose the solution above...
Now, how do I tell PHP to make an array from the kids input, but only from the fields in which let’s say the “name” field was filled out in order to spend the necessary table’s rows. Another thing… the Array should also specify new levelID’s for each kid from 1 to 5. It would be great if you also show me how to deal with it after it’s created.
It's easy to select only rows with contents for at certain field: select * from relatives where Name <> 0 I hope this was of some help? regards Jesper Brunholm -- Phønix - Danish folkmusic from young musicians - http://www.phonixfolk.dk

« previous php.db (#19942) next »