Family Trees

[insert_php]

/* Author: Gerry Haran
* Original Program name: processFamily.php
* Bastardised version for WordPress: family-trees
* Sub menu in WordPress : Family Trees
* Menu structure in WordPress : World War 1 \ Families \ no sub menu displayed for this page
* Description: Program builds the family tree for one or more than one family based on the surname passed by Families
* Linked pages: Each name links to page Civilian Biography which shows civilian biography for serviceman selected by user
*
* Version 1.1
* 7 October 2016
* Function called getebFamilyOffspring($treeCode)
* Have added code to pull data on any offspring from the database (stored in table ‘children’) and display as part
* of the family tree
* Extra functions called: getebFamilyOffspring($treeCode);
*
* Version 1.0
* Functions called: getFamilyName($chosenID); getFamilies($chosenID); getebFamilyParents($treeCode);
* getebFamilyWifes($treeCode); getebFamilyTree($treeCode);
*
* Backed up as FamilyTrees.wp 21 April 2016
*
* Date of original program : 25 September 2014
* Date of WordPress program : 19 March 2016
*
* Revision 1.1 on 20 October 2017
* Changed display of dates of life where either birth or death dates not known so that instead of blank or ‘unknown’ now show ‘?’
* Revision backed up on 20 October 2017 as FamilyTrees_20Oct2017.wp
*
* Revision 1.2 on 23 October 2017
* A late entry in the database has a father who is a stepfather and so the surname of the father is different from
* the offspring surname (and incidentally the mother’s surname; so the way of storing the parent’s forenames only
* in the database and displaying father’s name pulling the forename from the database and concatenating it with the offspring
* surname in $chosenFamilyName does not work for this instance. To fix this, the concatenation of $chosenFamilyName is
* removed and the database table parents is modified so that the name stored for the father is the full name, forename plus surname.
* Revision backed up on 23 October 2017 as FamilyTrees_23Oct2017.wp
*
* The user is presented with a list of all the family trees for the surname chosen by the user in the Family menu
* The table in the database is just a set of numbers that identify the surname, and identifies parents, brothers
* and wives in the database
* This page looks complicated but is really very simple. The integer in the GroupID field identifies all the
* members of all the families with a
* particular surname; it is this integer that is passed as a parameter to this page from the “Families” page.
* The table familytree is therefore searched
* on the field GroupID and returns all the tuples that match the GroupID value selected as an answerset.
* The code then uses the field famid to separate the answerset into the members of of different families who
* have the chosen surname.
* The code then uses the field levelNo to identify relationships in each family group. levelNo = 1 determines
* that the tuple refers to parents,
* levelNo = 2 determines that the tuple refers to a child who is a serviceman and there may be several child;
* levelNo = 4 determines that the tuple(s) refer to wife(s).
* The field memberID is then used to look up the member name in whichever table is appropriate for levelNo
* (ie parents, names [of brothers] or wifes)
* If there is more than one child serviceman, the code determines which wife is married to which brother and
* finally, depending on how many child servicemen, builds the family tree for each family found for the
* particular surname.
* Click a name to view the civilian biography for that serviceman name.
*/

$chosenID= $_GET[‘ebGroupName’];

$chosenFamily = getFamilyName($chosenID);
$chosenFamilyName = $chosenFamily[‘famname’];
$familyStyle= $chosenFamily[‘familyGroup’];
if ($familyStyle > 1)
{
$famText = ‘ families’;
}
else
{
$famText = ‘ family’;
}

echo “

Family tree for $chosenFamilyName $famText
\n”;
echo “

\n”;
/*echo “Have fetched ID from POST as $chosenID.
\n”;*/

$ebFamilyCodes = getfamilies($chosenID);
$dss = sizeof($ebFamilyCodes);
/*echo (“number of family codes is $dss
\n”);*/

for ($i=1;$i<=sizeof($ebFamilyCodes);$i++) { $familyNo=$ebFamilyCodes[$i]['famID']; $treeCode = $familyNo; $parentsInfo = getebFamilyParents($treeCode); $father = $parentsInfo['father']; $mother = $parentsInfo['mother']; if ((empty ($father)) and (empty($mother))) { $elders = 'Parents identity not found'; } else { /* Rev 1.2 changed following line to remove concatenation of $chosenFamilyName $elders = $father." ".$chosenFamilyName." = ".$mother;*/ $elders = $father." = ".$mother; } /*echo ("Just before calling getebFamilyWifes
“); */
$ebWifeInfo = getebFamilyWifes($treeCode);

/*echo (“Just AFTER calling getebFamilyWifes
“); */

/*if (! empty ($ebWifeInfo))
{
$bbb = sizeof($ebWifeInfo);
echo (“Number of wifes is $bbb
“);
}
else
{
echo (“No wife found
“);
}

initialise the child variables used to capture child data */

$child1 = “”;
$child2 = “”;
$child3 = “”;

$child1Wife = “”;
$child2Wife = “”;
$child3Wife = “”;

$child1Offspring1 = “”;
$child1Offspring2 = “”;
$child2Offspring1 = “”;
$child2Offspring2 = “”;
$child3Offspring1 = “”;
$child3Offspring2 = “”;
$child1Offspring1Birth = “”;
$child1Offspring2Birth = “”;
$child2Offspring1Birth = “”;
$child2Offspring2Birth = “”;
$child3Offspring1Birth = “”;
$child3Offspring2Birth = “”;
$NeedDownBox = “No”;

/*echo (“Just before calling getebFamilyOffspring
“); */
$ebOffspringInfo = getebFamilyOffspring($treeCode);
/*echo (“Just AFTER calling getebFamilyOffspring
“); */
/*
if (! empty ($ebOffspringInfo))
{
$xxxx =sizeof($ebOffspringInfo);
echo(“XXX number of offspring is $xxxx”);

for ($cc=1;$cc<=sizeof($ebOffspringInfo);$cc++) { $offSpringForename = $ebOffspringInfo[$cc]['cforename']; $offSpringMiddle = $ebOffspringInfo[$cc]['cmiddle']; $offSpringFather = $ebOffspringInfo[$cc]['EBfather']; $offSpringfullname = $offSpringForename." ".$offSpringMiddle; $offspringbirth = $ebOffspringInfo[$cc]['year(bdate)']; $y = sizeof($ebOffspringInfo); echo ("Number of offSpring is $y
“);
Fr debugging
echo (“

    “);
    echo (“

  • $offSpringfullname has the father $offSpringFather
  • \n”);
    echo (“

  • $offSpringfullname has birth date $offspringbirth
  • \n”);

    echo (“

“);
$y = sizeof($ebOffspringInfo);
echo (“Number of offSpring is $y
“);

}
}
else
{
echo (“no offspring found”);
}
*/
/*echo (“Just before calling getebFamilyTree
“); */
$ebFamilyTreeInfo = getebFamilyTree($treeCode);
/* echo (“Just AFTER calling getebFamilyTree
“); */

for ($k=1;$k<=sizeof($ebFamilyTreeInfo);$k++) { $SonID = $ebFamilyTreeInfo[$k]['ebID']; $forename=$ebFamilyTreeInfo[$k]['forename']; $middlename=$ebFamilyTreeInfo[$k]['middle']; $surname=$ebFamilyTreeInfo[$k]['surname']; $fullname=$forename." ".$middlename." ".$surname; if (empty ($ebFamilyTreeInfo[$k]['year(birth)'])) { $birthYear = '?'; } else { $birthYear=$ebFamilyTreeInfo[$k]['year(birth)']; } if (empty ($ebFamilyTreeInfo[$k]['year(death)'])) { $deathYear = '?'; } else { $deathYear=$ebFamilyTreeInfo[$k]['year(death)']; } $lifeYears=$birthYear."-".$deathYear; /* $z = sizeof($ebFamilyTreeInfo); echo ("Number of brothers is $z
“);

For debugging

echo (“

    “);
    echo (“

  • $fullname has the ID $SonID with life years $lifeYears
  • \n”);
    echo (“

“);

echo (“
“);

echo (“$fullname has the ID $SonID with life years $lifeYears\n”);*/
${‘child’.$k.’Ref’} = $SonID;
${‘child’.$k} = $fullname;
${‘child’.$k.’dates’} = ‘(‘.$lifeYears.’)’;
/*echo (“Just before IF ebWifeInfo
“); */
if (! empty($ebWifeInfo))
{
for ($z=1; $z<=sizeof($ebWifeInfo);$z++) { $wifeforename = $ebWifeInfo[$z]['marriedN']; $wifesurname = $ebWifeInfo[$z]['nee']; $husband = $ebWifeInfo[$z]['husbandID']; /*echo ("$wifeforename has Husband with ID of $husband and SonID is $SonID
“);*/

if ($husband == $SonID)
{
/*echo (“In if test in z loop.ID for husband match for $wifeforename is $husband
“);
echo (“and in if test and value of k is $k
“);*/

if ($k == 1)
{
/*echo (“and in if test k = 1 section and value of k is $k
“);*/

$child1Wife = ‘ = ‘.$wifeforename.” “.$wifesurname;

/* echo (“child1Wife is $child1Wife”);*/

}
else
if ($k == 2)
{

/*echo (“and in if test k = 2 section and value of k is $k
“);*/

$child2Wife = ‘ = ‘.$wifeforename.” “.$wifesurname;
/*echo (“child2Wife is $child2Wife
“);*/
}
else
if ($k == 3)
{
/*echo (“and in if test k = 3 section and value of k is $k
“);*/

$child3Wife = ‘ = ‘.$wifeforename.” “.$wifesurname;
/*echo (“child3Wife is $child3Wife
“); */
}

}
/*echo (“Inside for loop at loop $z and wife1 is $child1Wife”);
*/
}
}
/*echo (“outside For loop and wife 1 is $child1Wife”);

echo (“Have just reached FOR loop for offspring
“);*/

if (! empty ($ebOffspringInfo))
{
/*$dfgh = sizeof($ebOffspringInfo);
echo (“DFGH number of ofspring is $dfgh
“);*/
for ($cc=1;$cc<=sizeof($ebOffspringInfo);$cc++) { $offSpringForename = $ebOffspringInfo[$cc]['cforename']; $offSpringMiddle = $ebOffspringInfo[$cc]['cmiddle']; $offSpringFather = $ebOffspringInfo[$cc]['EBfather']; $OffspringbirthYear= $ebOffspringInfo[$cc]['year(bdate)']; /* For debugging echo ("Offspring forename is $offSpringForename
“);

echo (“Offspring birth year is $OffspringbirthYear
“);
*/

if ($offSpringFather == $SonID)
{
/*echo (“ID for offspring match is $offSpringFather
“);
echo (“and in if test and value of k is $k
“);*/

if ($k == 1)
{
/* echo (“and in if test k = 1 section and value of k is $k
“); */

if ($cc == 1)
{
$child1Offspring1 = $offSpringForename.” “.$offSpringMiddle;
$child1Offspring1Birth = ‘(‘ .$OffspringbirthYear.’)’;

/*echo (“in k=1 and cc = 1 and offspring1 is $child1Offspring1 and birth is $child1Offspring1Birthr
\n”); */

}
elseif ($cc == 2)
{
$child1Offspring2 = $offSpringForename.” “.$offSpringMiddle;
$child1Offspring2Birth = ‘(‘ . $OffspringbirthYear . ‘)’;

/* echo (“in k=1 and cc = 2 and offspring2 is $child1Offspring2
\n”); */

}
}
else
if ($k == 2)
{

/*echo (“and in if test k = 2 section and value of k is $k and value of cc is $cc
“); */

if ($cc == 1)
{
$child2Offspring1 = $offSpringForename.” “.$offSpringMiddle;
$child2Offspring1Birth = ‘(‘ . $OffspringbirthYear . ‘)’;

/* echo (“in k=2 and cc = 1 and child2Offspring1 is $child2Offspring1
\n”); */

}
elseif ($cc == 2)
{
$child2Offspring2 = $offSpringForename.” “.$offSpringMiddle;
$child2Offspring2Birth = ‘(‘ . $OffspringbirthYear . ‘)’;

/* echo (“in k=2 and cc = 2 and offspring1 is $child2Offspring1”); */

}
}
else
if ($k == 3)
{

/* echo (“and in if test k = 3 section and value of k is $k
“);*/

if (cc == 1)
{
$child3Offspring1 = $offSpringForename.” “.$offSpringMiddle;
$child3Offspring1Birth = ‘(‘. $OffspringbirthYear . ‘)’;
}
elseif ($cc == 2)
{
$child3Offspring2 = $offSpringForename.” “.$offSpringMiddle;
$child3Offspring2Birth = ‘(‘. $OffspringbirthYear . ‘)’;
}
}
}
}
/* Fr debugging
echo (“

    “);
    echo (“

  • $offSpringfullname has the father $offSpringFather
  • \n”);
    echo (“

“);
$y = $cc – 1;
echo (“Number of offSpring is $y
“);
*/

}

}
$m = $k – 1;

/*For debugging

echo (“Number of brothers is $m
“);
echo (“Child1 is $child1
“);
echo (“Child2 is $child2
“);
$child1Wife = ” = “.’DummyWife1′;
$child2Wife = ” = “.’DummyWife2′;
echo (“child1wife is $child1Wife
“);
echo (“child2wife is $child2Wife
“);
echo (“child1Offspring1 is $child1Offspring1
“);
echo (“child2Offspring1 is $child2Offspring1
“);
echo (“m is $m”);*/

if ($m == 3)
{
$parentsClass = ‘parentsLeft’;
}
else
{
$parentsClass = ‘parents’;
}

/*echo (“

“);*/

echo (“

$elders

“);

$placehold =””;
/* temp try fix
$m=1;*/
switch ($m)
{
case 1 :
echo (“

$placehold

“);
echo “

$child1$child1Wife
$child1dates

“;

if ($child1Offspring1 != “”)
{
echo (“

$placehold

“);
}

echo (“

$child1Offspring1 $child1Offspring1Birth

“);
echo (“

$child1Offspring2 $child1Offspring2Birth

“); break;

case 2 :
$chSpouseFlag = 0;

/*because of limited screen width, need to set style dependent on how many wives there are; first count with $chSpouseFlag
thus have four poss values; 0 no wives, 1 have child1wife, 2 have child2wife, 3 have both wives

echo (“In Switch m=2 and child1Offspring1 is $child1Offspring1
“);
echo (“In Switch m=2 and child2Offspring1 is $child2Offspring1
“); */

if (!empty($child1Wife))
{
$chSpouseFlag = 1;
}
if (!empty($child2Wife))
{
$chSpouseFlag = $chSpouseFlag + 2;

}
/*echo (“In Switch case 2 and chSpouseFlag = $chSpouseFlag
“);*/
if ($chSpouseFlag == 0)
{
$leftSon = “leftchildUnmarried”;
$rightSon = “rightchildPosUnmarried”;
}
elseif ($chSpouseFlag == 1)
{
$leftSon = “leftchild”;
$rightSon = “rightchildPosUnmarried”;
}
elseif ($chSpouseFlag == 2)
{
$leftSon = “leftchildUnmarried”;
$rightSon = “rightchildPos”;
}
else
{
$leftSon = “leftchild”;
$rightSon = “rightchildPos”;
}
/*echo (“chSpouseFlag is $chSpouseFlag “);*/
if ($child1Offspring1 != “”)
{
$RightOffspring = “OffSpringRight”;
}
else
{
$RightOffspring = “OffSpringRightEx”;

}

echo “

$placehold

“;
echo “

$placehold

“;

echo (“$child1 $child1Wife
$child1dates
“);

echo (“$child2$child2Wife
$child2dates

“);

if ($child1Offspring1 != “”)
{
echo (“

$placehold

“);
}

if ($child2Offspring1 != “”)
{
echo (“

$placehold

“);
}

echo (“$child1Offspring1 $child1Offspring1Birth“);
echo (“$child2Offspring1 $child2Offspring1Birth“); break;

case 3 :
echo (“

$placehold

“);

echo “

$child1$child1Wife
$child1dates

“;

echo (“

$placehold

“);

echo “

$child2$child2Wife
$child2dates

“;

echo (“

$placehold

“);

echo “

$child3$child3Wife
$child3dates

“; break;
default : echo(“No information found in the database”);

}
/*echo (“


“);*/
echo (“


“);
}
$n = $i – 1;

/*echo (“Number of families is $n”);
*/
[/insert_php]