Page 1 of 1

Creating a table for adding data to MySQL Database

Posted: Thu May 15, 2008 6:39 am
by kdidymus
I have a challenge for you. I hope somebody can rise to it as you have with all of my other (often daft) questions.

Those of you who have been following my rocky introduction to PHP and MySQL will know that I am creating a family tree website.

Okay. So at present I have three entries in my database. I have to add at LEAST a thousand more and doing that manually is a pain in the backside.

I downloaded MySQL Administrator 1.2.12 which allows me to edit table data but it's slow and quite fiddly to do.

SO...

What I want to do is create a PHP page with a large form. I populate the fields and press SUBMIT and the form enters the information in to my database.

I have created the following (VERY rough draft) HTML:

Code: Select all

<html>
 
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>URN</title>
</head>
 
<body>
 
<table border="0" width="100%" cellspacing="0" cellpadding="0"><form>
    <tr>
        <td><b><font face="Arial" size="1" color="#FF0000">DATABASE PASSWORD:</font></b></td>
        <td><font face="Arial" size="1"><input type="text" name="T1" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font size="1" face="Arial">URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T92" size="20"></font></td>
    </tr>
    <tr>
        <td><font size="1" face="Arial">SURNAME:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T2" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font size="1" face="Arial">SURNAME:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T91" size="20"></font></td>
    </tr>
    <tr>
        <td><font size="1" face="Arial">FORENAME:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T90" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font size="1" face="Arial">MIDDLE NAMES:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T35" size="20"></font></td>
    </tr>
    <tr>
        <td><font size="1" face="Arial">DATE OF BIRTH:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T5" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font size="1" face="Arial">PLACE OF BIRTH:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T6" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">MOTHER:</font></td>
        <td><input type="text" name="T7" size="20"></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">MOTHER URN:</font></td>
        <td><input type="text" name="T9" size="20"></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">FATHER:</font></td>
        <td><input type="text" name="T8" size="20"></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">FATHER URN:</font></td>
        <td><input type="text" name="T10" size="20"></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SIBLING 1:</font></td>
        <td><input type="text" name="T11" size="20"></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SIBLING 1 URN:</font></td>
        <td><input type="text" name="T12" size="20"></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SIBLING 2:</font></td>
        <td><input type="text" name="T13" size="20"></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SIBLING 2 URN:</font></td>
        <td><input type="text" name="T14" size="20"></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SIBLING 3:</font></td>
        <td><input type="text" name="T15" size="20"></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SIBLING 3 URN:</font></td>
        <td><input type="text" name="T16" size="20"></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SIBLING 4:</font></td>
        <td><input type="text" name="T17" size="20"></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SIBLING 4 URN:</font></td>
        <td><input type="text" name="T18" size="20"></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SIBLING 5:</font></td>
        <td><input type="text" name="T19" size="20"></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SIBLING 5 URN:</font></td>
        <td><input type="text" name="T20" size="20"></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SIBLING 6:</font></td>
        <td><input type="text" name="T21" size="20"></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SIBLING 6 URN:</font></td>
        <td><input type="text" name="T22" size="20"></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SIBLING 7:</font></td>
        <td><input type="text" name="T23" size="20"></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SIBLING 7 URN:</font></td>
        <td><input type="text" name="T24" size="20"></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SIBLING 8:</font></td>
        <td><input type="text" name="T25" size="20"></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SIBLING 8 URN:</font></td>
        <td><input type="text" name="T26" size="20"></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SIBLING 9:</font></td>
        <td><input type="text" name="T27" size="20"></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SIBLING 9 URN:</font></td>
        <td><input type="text" name="T28" size="20"></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SIBLING 10:</font></td>
        <td><input type="text" name="T29" size="20"></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SIBLING 10 URN:</font></td>
        <td><input type="text" name="T30" size="20"></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">CHRISTENING DATE:</font></td>
        <td><input type="text" name="T31" size="20"></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">CHRISTENING PLACE:</font></td>
        <td><input type="text" name="T32" size="20"></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 1:</font></td>
        <td><input type="text" name="T33" size="20"></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 1 URN:</font></td>
        <td><input type="text" name="T34" size="20"></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 1 MARRIAGE DATE:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T36" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 1 MARRIAGE PLACE:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T37" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 1:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T38" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 1 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T39" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 2:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T40" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 2 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T41" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 3:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T42" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 3 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T43" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 4:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T44" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 4 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T45" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 5:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T46" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 5 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T47" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 6:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T48" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 6 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T49" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 7:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T50" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 7 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T51" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 8:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T52" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 8 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T53" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 9:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T54" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 9 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T55" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 10:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T56" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 1 CHILD 10 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T57" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 2:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T58" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 2 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T59" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 2 MARRIAGE DATE:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T60" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 2 MARRIAGE PLACE:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T61" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 1:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T62" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 1 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T63" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 2:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T64" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 2 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T65" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 3:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T66" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 3 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T67" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 4:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T68" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 4 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T69" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 5:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T70" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 5 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T71" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 6:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T72" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 6 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T73" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 7:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T74" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 7 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T75" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 8:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T76" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 8 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T77" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 9:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T78" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 9 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T79" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 10:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T80" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SPOUSE 2 CHILD 10 URN:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T81" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">OCCUPATION:</font></td>
        <td><font size="1" face="Arial"><input type="text" name="T82" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">DATE OF DEATH:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T83" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">PLACE OF DEATH:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T84" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">CAUSE OF DEATH:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T85" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">NOTES:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T86" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">PHOTOGRAPHS:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T87" size="20"></font></td>
    </tr>
    <tr>
        <td><font face="Arial" size="1">CENSUS:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T88" size="20"></font></td>
        <td>&nbsp;</td>
        <td><font face="Arial" size="1">SCRAPBOOK:</font></td>
        <td><font face="Arial" size="1"><input type="text" name="T89" size="20"></font></td>
    </tr>
    <tr>
        <td colspan="5">&nbsp;</td>
    </tr>
    <tr>
        <td><input type="submit" value="Submit" name="B4"></td>
        <td><input type="reset" value="Reset" name="B5"></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr></form>
</table>
 
</body>
 
</html>
Any idea how I can make this work as a PHP file which does what I want it to do?

This is a lot to ask so I'll fully understand if your reply is to buy a book but I have one and it doesn't help!!!!

Thank you.

Kris.

Re: Creating a table for adding data to MySQL Database

Posted: Thu May 15, 2008 6:53 am
by kdidymus
Further to the above, I've included the DATABASE PASSWORD field as a security measure to ensure that no Tom, Dick or Harry can add spurious data to my file.

My database uses the following strings:

$urn, $surname, $forename, $middlenames, $dateofbirth, $placeofbirth, $mother, $father, $sibling1, $sibling2, $sibling3, $sibling4, $sibling5, $sibling6, $sibling7, $sibling8, $sibling9, $sibling10, $christeningdate, $christeningplace, $spouse1, $spouse1marriagedate, $spouse1marriageplace, $spouse1child1, $spouse1child2, $spouse1child3, $spouse1child4, $spouse1child5, $spouse1child6, $spouse1child7, $spouse1child8, $spouse1child9, $spouse1child10, $spouse2, $spouse2marriagedate, $spouse2marriageplace, $spouse2child1,, $spouse2child2, $spouse2child3, $spouse2child4, $spouse2child5, $spouse2child6, $spouse2child7, $spouse2child8, $spouse2child9, $spouse2child10, $occupation, $dateofdeath, $placeofdeath, $causeofdeath, $notes, $photographs, $census, $scrapbook, $certificates, $sibling1urn, $sibling2urn, $sibling3urn, $sibling4urn, $sibling5urn, $sibling6urn, $sibling7urn, $sibling8urn, $sibling9urn, $sibling10urn, $spouse1urn, $spouse1child1urn, $spouse1child2urn, $spouse1child3urn, $spouse1child4urn, $spouse1child5urn, $spouse1child6urn, $spouse1child7urn, $spouse1child8urn, $spouse1child9urn, $spouse1child10urn, $spouse2child1urn, $spouse2child2urn, $spouse2child3urn, $spouse2child4urn, $spouse2child5urn, $spouse2child6urn, $spouse2child7urn, $spouse2child8urn, $spouse2child9urn, $spouse2child10urn.

Not sure if this helps but wanted to give you every help possible in order that you might be able to help me.

Re: Creating a table for adding data to MySQL Database

Posted: Thu May 15, 2008 7:54 am
by aceconcepts
What you want to do is check whether the form has been submitted and if so then get the form fields and INSERT them into your database.

Code: Select all

 
//check if form is submitted
if(isset($_POST['b4']))
{
   //get form fields
      $urn=$_POST['T92'];   //i would suggest using descriptive variable and form element name i.e. $urn and $_POST['urn']
      $surname=$_POST['T2']   //again, change you form field "T2" to surname
 
   //insert into database
      $insertSql=mysql_query("INSERT INTO TABLE(column1, column2) VALUES('$urn', '$surname')");
}
 
The above is very rough and requires validation to work efficiently.

The columns (column1 and column2) are examples - these should be the fields in your database tables.

Also, where it says INSERT INTO TABLE - TABLE should be replaced by the table name from your database.

Re: Creating a table for adding data to MySQL Database

Posted: Thu May 15, 2008 8:42 am
by kdidymus
That's superb. My book was alluding to that answer but never quite explained it outside of their limited example.

So in terms of setting up the action for the form what's needed there? (i.e. <form action="post">)

You're a great help and I thank you from the bottom of my heart. I'll owe you NUMEROUS pints of beer before this little project is done!

KD.

Re: Creating a table for adding data to MySQL Database

Posted: Thu May 15, 2008 9:10 am
by timsewell
<form id="[form name]" form action="[path/filename to script file]" method="POST">

Re: Creating a table for adding data to MySQL Database

Posted: Thu May 15, 2008 9:11 am
by aceconcepts
Haha - I like Leffe so you can send me a crate :D

Anyway, the method is "how" you will be submitting the form data - POST or GET (GET send the data via the url - POST is a hidden array of your data).

So your form declaration should look like this:

Code: Select all

 
<form name="form1" method="post" action="">
 
</form>
 
No "action" has been declared because you can tell the form to submit to itself by having no action parameter.

So how do you get the data?

Simply include a file at the top of your script:

This will be your main form:

Code: Select all

 
include"validation.php";   //The content of this file will be executed only if the the below form has been submitted
 
echo'<form name="form1" method="post" action="">';
 
echo'</form>';
 
This is validation.php

Code: Select all

 
if(isset($_POST['submitButton']))
{
   //get the form data
      $firstName=$_POST['firstName'];
 
   //etc etc etc...
}
 

Re: Creating a table for adding data to MySQL Database

Posted: Fri May 16, 2008 2:14 am
by kdidymus
Superb. I've created a separate PHP file which takes the $_POST data, cleans it and checks it and then submits it to the database. This works fine!

Kris.

Re: Creating a table for adding data to MySQL Database

Posted: Fri May 16, 2008 6:03 am
by dbemowsk
kiddymus,
I would be curious to see your database tables. From looking at your html form and variables listed above it would seem that this could use quite a bit of normalization. I think from looking at your example that you would have a lot of empty fields causing a lot of data redundancy and wasted space.

In order to normalize this a bit, I would look at one person and figure out what data is relevant to that one person. For example:

***$person_id***, $urn, $surname, $forename, $middlenames, $dateofbirth, $placeofbirth, $christeningdate, $christeningplace, $occupation, $dateofdeath, $placeofdeath, $causeofdeath, $notes, $photographs, $census, $scrapbook, $certificates

I would make this your main database table. From there I would create some other tables such as a siblings table. The way the siblings table would work is that you would have 2 fields. The 2 fields would contain 2 person_ids. The first is the id of the person/sibling you are referencing, and the next is the id of the person they are related to. Along the same lines, I would have a table called mothers and one called fathers. Again I would have 2 person_ids. This would allow you to say person_id 5 is the mother/father of person_id 7. Then have as many entries as needed saying that person_id 5 is the mother/father of person_id 10 etc... Doing it this way you are not limited to the number of children.

You could further break that all down and have tables for your notes, photographs, scrapbook entries and certificates. Simply create a tables called notes, photographs, etc... and have 2 fields. For the notes table you would have person_id, and note for the two fields. This way you can have as many notes related to one person as you want.

From what I have described above you should be able to break down your database tables quite a bit. Once you have all this, all the information should be referenced to a person_id. If you are looking at a particular person, you would then send a query to the mothers table and say "SELECT person_id, mother_id FROM mothers WHERE person_id = $person_id". Once you have obtained that you can go back and query your table of people and say "SELECT * FROM people WHERE person_id = $mother_id" to get the information about the mother, and so on.

Being that the data you are working with is in the form of a tree, you may want to look into a couple data storage algorithms called "adjacency list model" and "modified pre order tree traversal". Here is a link that explains these a bit http://www.sitepoint.com/article/hierar ... a-database. I used a lot of this information to build a navigation menu for a web application that I am building

I hope the information I have given here was helpful. I may even use some information from this post to do an article on database normalization to post on my website http://www.phpwebscripting.com.

dbemowsk
See my PHP coding articles at http://www.phpwebscripting.com