Thanks for the input. I wasn't considering the possibility of making a
new table for kids until now which seems pretty logic when trying to
save space. The only thing missing now is how to assign a unique
relation number for each kid/relative. That's 1 for the first born, 2
for the second one, etc... and it can't be done by auto_incrementing,
for it will start over when a new member is inserted... i.e. the
relatives table should show:
Member level name address
0025 1 Jr.1 same as 0025/0
0025 2 Jr.2 same as 0025/0
0026 1 Jr.1 same as 0026/0
0026 2 Jr.2 same as 0026/0
0026 3 Jr.3 same as 0026/0
The catch would be to make PHP to auto assign the relatives "level" by
knowing it has to start from $i=1 and loop $i++ until no other kid is
inserted. Now that I write it, it seems I could use a for loop, but what
should be the structure of it using the $name <> 0 you told me?
> -----Original Message-----
> From: Jesper Brunholm [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 21, 2002 6:56 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: [PHP] Re: ARRAY, IF & INSERT
> (i am new to these groups, but shouldn't there be a follow-up-to on a
> César aracena wrote:
> > I have this form in which one Administrator can insert new members
> > 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
> > 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
> select members.Name, members.ID, relatives.Name as RelativeName,
> 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
> > 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
> 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
> > from the fields in which let’s say the “name” field was filled out
> > 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
> > 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?
> Jesper Brunholm
> Phønix - Danish folkmusic from young musicians -
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php