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 nameaddress
00251 Jr.1same as 0025/0
00252 Jr.2same as 0025/0
00261 Jr.1same as 0026/0
00262 Jr.2same as 0026/0
00263 Jr.3same 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?
Thanks
> -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
> 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
> > members sons & daughters. I want to display a table with text
inserts
> > into the admin can type lets 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 lets say the name field was filled out
in
> > order to spend the necessary tables rows. Another thing
the Array
> > should also specify new levelIDs for each kid from 1 to 5. It would
be
> > great if you also show me how to deal with it after its 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
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php