Free Search for Ancestors';
echo '
You can search this genealogy database in two ways:
';
echo '
';
echo '- Search for a specific ancestor. Use the first Ancestor Search form and provide as much as you know about that ancestor.
';
echo '- Search for all people with a specific surname. A second Surname Search form is provided for this type of genealogy search.
';
echo '
';
}
else {
$con = mysqli_connect("localhost","uetsthoc_cdi","Eden0609","uetsthoc_ancestor");
// Check connection
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// Set up the different type of queries
$query_modifed = false; //Whether or not the query needed to simplified in order to get some results
if (!empty($lastname)){
$query_built = false;
while (!$query_built) { // Reduce the query in an attempt to get results
$query_string = "SELECT * FROM records WHERE ";
if ($gender == "f"){
$query_string .= "((wife_last_name_metaphone = '" . metaphone($lastname) ."' ";
if (!empty($firstname))
$query_string .= "AND MATCH(wife_full_name) AGAINST ('". addslashes($firstname) ."') ";
if (!empty($spfirstname) || !empty($splastname)){
$spfullname = trim($spfirstname . " " . $splastname);
$query_string .= "AND MATCH(husband_full_name) AGAINST ('". addslashes($spfullname) ."')";
}
$query_string .= ") ";
if (!empty($spfirstname) && !empty($splastname)){
$fullname = trim($firstname . " " . $lastname);
$query_string .= "OR (husband_last_name_metaphone = '" . metaphone($splastname) ."' AND MATCH(husband_full_name) AGAINST ('". addslashes($spfirstname) ."') AND MATCH(wife_full_name) AGAINST ('". addslashes($fullname) ."')) ";
}
$query_string .= ")";
if (!empty($birthloc)){
if (!empty($birthyear) && $birthyear < 1864 && ($birthloc == "VA" || $birthloc == "WV"))
$query_string .= " AND (wife_birth_location = 'VA' OR wife_birth_location = 'WV') ";
else
$query_string .= " AND wife_birth_location = '". $birthloc ."'";
}
if (!empty($spbirthloc)){
if (!empty($spbirthyear) && $spbirthyear < 1864 && ($spbirthloc == "VA" || $spbirthloc == "WV"))
$query_string .= " AND (husband_birth_location = 'VA' OR husband_birth_location = 'WV') ";
else
$query_string .= " AND husband_birth_location = '". $spbirthloc ."'";
}
if (!empty($birthyear)){
$startbirthyear = $birthyear - 10;
$endbirthyear = $birthyear + 10;
$query_string .= " AND wife_birth >= ". $startbirthyear ." AND wife_birth <= ". $endbirthyear;
}
if (!empty($spbirthyear)){
$spstartbirthyear = $spbirthyear - 10;
$spendbirthyear = $spbirthyear + 10;
$query_string .= " AND husband_birth >= ". $spstartbirthyear ." AND husband_birth <= ". $spendbirthyear;
}
}
else {
$query_string .= "((husband_last_name_metaphone = '" . metaphone($lastname) ."' ";
if (!empty($firstname))
$query_string .= "AND MATCH(husband_full_name) AGAINST ('". addslashes($firstname) ."') ";
if (!empty($spfirstname) || !empty($splastname)){
$spfullname = trim($spfirstname . " " . $splastname);
$query_string .= "AND MATCH(wife_full_name) AGAINST ('". addslashes($spfullname) ."')";
}
$query_string .= ") ";
if (!empty($spfirstname) && !empty($splastname)){
$fullname = trim($firstname . " " . $lastname);
$query_string .= "OR (wife_last_name_metaphone = '" . metaphone($splastname) ."' AND MATCH(wife_full_name) AGAINST ('". addslashes($spfirstname) ."') AND MATCH(husband_full_name) AGAINST ('". addslashes($fullname) ."')) ";
}
$query_string .= ")";
if (!empty($birthloc)){
if (!empty($birthyear) && $birthyear < 1864 && ($birthloc == "VA" || $birthloc == "WV"))
$query_string .= " AND (husband_birth_location = 'VA' OR husband_birth_location = 'WV') ";
else
$query_string .= " AND husband_birth_location = '". $birthloc ."'";
}
if (!empty($spbirthloc)){
if (!empty($spbirthyear) && $spbirthyear < 1864 && ($spbirthloc == "VA" || $spbirthloc == "WV"))
$query_string .= " AND (wife_birth_location = 'VA' OR wife_birth_location = 'WV') ";
else
$query_string .= " AND wife_birth_location = '". $spbirthloc ."'";
}
if (!empty($birthyear)){
$startbirthyear = $birthyear - 10;
$endbirthyear = $birthyear + 10;
$query_string .= " AND husband_birth >= ". $startbirthyear ." AND husband_birth <= ". $endbirthyear;
}
if (!empty($spbirthyear)){
$spstartbirthyear = $spbirthyear - 10;
$spendbirthyear = $spbirthyear + 10;
$query_string .= " AND wife_birth >= ". $spstartbirthyear ." AND wife_birth <= ". $spendbirthyear;
}
}
$result = mysqli_query($con,$query_string);
$num_rows = mysqli_num_rows($result);
if ($num_rows > 0) {
$query_built = true;
}
else { // Query may be too restrictive. Iteratively, remove some parameters.
if (!empty($birthyear) || !empty($spbirthyear)){
$birthyear = "";
$spbirthyear = "";
$query_modified = true;
}
else if (!empty($birthloc) || !empty($spbirthloc)){
$birthloc = "";
$spbirthloc = "";
$query_modified = true;
}
else if (!empty($splastname)){
$splastname = "";
$query_modified = true;
}
else if (!empty($spfirstname)){
$spfirstname = "";
$query_modified = true;
}
else if (!empty($firstname)){
$firstname = "";
$query_modified = true;
}
else {
$query_built = true; // Give up
}
}
}
}
else if (!empty($surname)){
$query_built = false;
while (!$query_built) { // Reduce the query in an attempt to get results
if ($criteria == "similar"){
$query_string = "SELECT * FROM records WHERE husband_last_name_metaphone = '" . metaphone($surname) . "' OR wife_last_name_metaphone = '" . metaphone($surname) . "'";
$query_built = true; // This all that can be done to find more records
}
else {
$query_string = "SELECT * FROM records WHERE husband_last_name = '" . $surname . "' OR wife_last_name = '" . $surname . "'";
}
$result = mysqli_query($con,$query_string);
$num_rows = mysqli_num_rows($result);
if ($num_rows > 0) {
$query_built = true;
}
else {
$criteria = "similar";
$query_modified = true;
}
}
}
else if (!empty($author)){
$query_string = "SELECT * FROM records WHERE author_id = '" . $author . "'";
$result = mysqli_query($con,$query_string);
$num_rows = mysqli_num_rows($result);
}
if ($num_rows == 0){
if (!empty($lastname)){
echo '
No Search Results for ' . $name .'
';
echo '
No results could be found for the Ancestor Search criteria shown at the left. ';
}
else if (!empty($surname)){
echo '
No Search Results for the ' . $surname . ' Surname
';
echo '
No results could be found for the Surname Search criteria shown at the left. ';
}
else if (!empty($author)){
echo '
No Search Results for Researcher: ' . $author . '
';
echo '
No results could be found for the researcher requested. ';
}
else {
echo '
No Search Results
';
echo '
No results could be found for the type of search you requested. ';
}
if (!empty($lastname) && $query_modified)
echo 'An attempt was made to simplify the search by modifying some of the search criteria. Nevertheless, no records were found to match the simplified search. Sorry.';
if (!empty($surname) && $query_modified)
echo 'Searching on an exact name returned no matches. The search was expanded to include similar names. Unfortunately, no records were found that had similar names. Sorry.';
echo '
';
echo '
If you are interested in advice on other options for researching your genealogy, try Genealogy Search Advice.
';
}
else {
//This is the number of results displayed per page
$page_entries = 10;
//The page number of our last page
$last_page = ceil($num_rows/$page_entries);
if ($pagenum < 1)
$pagenum = 1;
else if ($pagenum > $last_page)
$pagenum = $last_page;
//This sets the range to display in our query
$range = ' limit ' .($pagenum - 1) * $page_entries .',' .$page_entries;
$result = mysqli_query($con,$query_string . $range);
if (!empty($lastname))
echo '
' . $name . ' Name Search Results
';
else if (!empty($surname))
echo '
' . $surname . ' Surname Search Results
';
else if (!empty($author))
echo '
Records from Researcher: ' . $author . '
';
else
echo '
Search Results
';
if (!empty($lastname) && $query_modified)
echo '
Note: The results below are the result of modifying some of the search criteria in order to increase the number of records found.
';
if (!empty($surname) && $query_modified)
echo '
Note: The results below are the result of changing the surname search criteria from "exact" to "similar" in order to increase the number of records found.
';
echo '
Page: '. $pagenum .' of '. $last_page .'
Total records found: '. number_format($num_rows) .'
';
echo '
';
echo 'Ancestor and Spouse | Additional Information |
';
while($row = mysqli_fetch_array($result)){
if ((!empty($lastname) && $gender == "f") || (!empty($surname) && $criteria == "similar" && strcasecmp(metaphone($surname), $row['wife_last_name_metaphone']) == 0) || (!empty($surname) && $criteria == "exact" && strcasecmp($surname, $row['wife_last_name']) == 0)){
$fullName = trim($row['wife_full_name'], ", ");
$birth = trim($row['wife_birth']);
if (!empty($row['wife_birth_location'])){
$wife_birth_location_name = getLocationName($row['wife_birth_location']);
if (!empty($birth)){
if (strcasecmp($birth, "OF") == 0)
$birth = "of " . $wife_birth_location_name;
else
$birth .= ", " . $wife_birth_location_name;
}
else {
$birth = $wife_birth_location_name;
}
}
$spouseName = trim($row['husband_full_name'], ", ");
$spouseBirth = trim($row['husband_birth']);
if (!empty($row['husband_birth_location'])){
$husband_birth_location_name = getLocationName($row['husband_birth_location']);
if (!empty($spouseBirth)){
if (strcasecmp($spouseBirth, "OF") == 0)
$spouseBirth = "of " . $husband_birth_location_name;
else
$spouseBirth .= ", " . $husband_birth_location_name;
}
else {
$spouseBirth = $husband_birth_location_name;
}
}
}
else {
$fullName = trim($row['husband_full_name'], ", ");
$birth = trim($row['husband_birth']);
if (!empty($row['husband_birth_location'])){
$husband_birth_location_name = getLocationName($row['husband_birth_location']);
if (empty($husband_birth_location_name))
$husband_birth_location_name = $row['husband_birth_location'] . ' (?)';
if (!empty($birth)){
if (strcasecmp($birth, "OF") == 0)
$birth = "Other Event in " . $husband_birth_location_name;
else
$birth .= ", " . $husband_birth_location_name;
}
else {
$birth = $husband_birth_location_name;
}
}
$spouseName = trim($row['wife_full_name'], ", ");
$spouseBirth = trim($row['wife_birth']);
if (!empty($row['wife_birth_location'])){
$wife_birth_location_name = getLocationName($row['wife_birth_location']);
if (empty($wife_birth_location_name))
$wife_birth_location_name = $row['wife_birth_location'] . ' (?)';
if (!empty($spouseBirth)){
if (strcasecmp($spouseBirth, "OF") == 0)
$spouseBirth = "Other Event in " . $wife_birth_location_name;
else
$spouseBirth .= ", " . $wife_birth_location_name;
}
else {
$spouseBirth = $wife_birth_location_name;
}
}
}
$marriage = trim($row['marriage']);
if (!empty($row['marriage_location'])){
$marriage_location_name = getLocationName($row['marriage_location']);
if (empty($marriage_location_name))
$marriage_location_name = $row['marriage_location'] . ' (?)';
if (!empty($marriage)){
if (strcasecmp($marriage, "OF") == 0)
$marriage = "Other Event in " . $marriage_location_name;
else
$marriage .= ", " . $marriage_location_name;
}
else {
$marriage = $marriage_location_name;
}
}
$authorID = $row['author_id'];
if ($shade){
echo '';
$shade = false;
}
else {
echo '
';
$shade = true;
}
echo '';
echo 'Name: ' . $fullName . ' ';
echo 'Birth: ' . $birth . ' ';
echo 'Spouse: ' . $spouseName . ' ';
echo 'Birth: ' . $spouseBirth . ' ';
echo 'Marriage: ' . $marriage;
echo ' | ';
echo '';
if (!empty($authorID) && (!empty($lastname) || !empty($surname)))
echo 'Researcher: '. $authorID .'. See all records from this researcher
';
else if (strcasecmp(trim($row['type']), "F!") == 0)
echo 'Obtain the source data for this record
';
// Set up Ancestry.com census search
$pattern = '/(.*?,\s)*(.+?)( .*)*/i';
$replacement = '$2';
$husband_first_name = ucfirst(strtolower(preg_replace($pattern, $replacement, $row['husband_full_name'])));
$husband_last_name = ucfirst(strtolower($row['husband_last_name']));
$husband_birth_year = $row['husband_birth'];
$husband_birth_location = getLocationName($row['husband_birth_location']);
$wife_first_name = ucfirst(strtolower(preg_replace($pattern, $replacement, $row['wife_full_name'])));
$wife_birth_year = $row['wife_birth'];
$wife_birth_location = getLocationName($row['wife_birth_location']);
$marriage_year = $row['marriage'];
$marriage_location = getLocationName($row['marriage_location']);
if (!empty($husband_last_name) && !empty($husband_first_name) && ($husband_birth_year > 1740 || $wife_birth_year > 1740 || $marriage_year > 1789) && !empty($wife_first_name)){
$ancestry_url = 'name='. $husband_first_name .'_'. $husband_last_name .'&gender=m&spouse='. $wife_first_name;
$ancestry_url .= '&birth='.$husband_birth_year;
if (!empty($husband_birth_location))
$ancestry_url .= '_'.$husband_birth_location;
echo '';
}
echo ' | ';
echo '
';
}
echo '
';
if ($num_rows > $page_entries){
echo '
Page [';
// Set up link
$page_link = "";
if (!empty($firstname))
$page_link .= "&firstname=".$firstname;
if (!empty($lastname))
$page_link .= "&lastname=".$lastname;
if (!empty($gender))
$page_link .= "&gender=".$gender;
if (!empty($birthyear))
$page_link .= "&birthyear=".$birthyear;
if (!empty($birthloc))
$page_link .= "&birthloc=".$birthloc;
if (!empty($spfirstname))
$page_link .= "&spfirstname=".$spfirstname;
if (!empty($splastname))
$page_link .= "&splastname=".$splastname;
if (!empty($spbirthyear))
$page_link .= "&spbirthyear=".$spbirthyear;
if (!empty($spbirthloc))
$page_link .= "&spbirthloc=".$spbirthloc;
if (!empty($surname))
$page_link .= "&surname=".$surname;
if (!empty($criteria))
$page_link .= "&criteria=".$criteria;
$page_link = trim($page_link, "&");
if (!empty($author))
$page_link .= "author=".$author;
for($i = 1; $i <= $last_page; $i++) {
if ($i == $pagenum) { //This is the current page. Don't make it a link.
echo ''.$i .' ';
}
else { // This is not the current page. Make it a link.
if (($i < 4) || ($i > $pagenum - 3 && $i < $pagenum + 3) || ($i > $last_page - 3))
echo ' '.$i.' ';
else if(($i > $pagenum - 6 && $i < $pagenum + 6))
echo ' .';
}
}
echo ']';
if ($pagenum > 1){
$previouspage = $pagenum - 1;
echo ' Previous ';
}
if ($pagenum < $last_page){
$nextpage = $pagenum + 1;
if (isset($previouspage))
echo ' | ';
echo ' Next ';
}
echo '
';
}
}
mysqli_close($con);
}
if (!empty($lastname) || !empty($surname)){
$con = mysqli_connect("localhost","uetsthoc_cdi","Eden0609","uetsthoc_ancestor");
// Check connection
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if (!empty($lastname))
$query_string = "SELECT * FROM yates WHERE metaphone = '" . metaphone($lastname) . "'";
else
$query_string = "SELECT * FROM yates WHERE metaphone = '" . metaphone($surname) . "'";
$result = mysqli_query($con,$query_string);
$num_rows = mysqli_num_rows($result);
if ($num_rows > 0){
echo '
Related Surname Records
';
if ($num_rows == 1)
echo '
Yates Publishing has records on the following surname:
';
else
echo '
Yates Publishing has records on the following related surnames:
';
echo '
';
while($row = mysqli_fetch_array($result)){
echo '- '. $row['surname'] .'
';
}
echo '
';
echo '
Go to the Yates Catalogue for more information.
';
}
mysqli_close($con);
}
if (!empty($author)){
$con = mysqli_connect("localhost","uetsthoc_cdi","Eden0609","uetsthoc_ancestor");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$query_string = "SELECT * FROM authors WHERE id = '" . $author . "'";
$result = mysqli_query($con,$query_string);
$num_rows = mysqli_num_rows($result);
if ($num_rows > 0){
$row = mysqli_fetch_array($result);
if (!empty($row['last_name'])){
echo '
Researcher Information
';
echo '
The researcher who provided this family information is:
';
echo '
';
echo $row['first_name'] .' '. $row['middle_name'] . ' ' . $row['last_name'] .'
';
echo $row['city'];
if (!empty($row['state'])){
if (!empty($row['city']))
echo ', '. $row['state'];
else
echo $row['state'];
}
echo '
';
if (!empty($row['file']))
echo '
The identifying file is: '. $row['file'] .'.
';
echo '
';
echo '
Contact Yates Publishing for more information on this researcher.
';
}
}
mysqli_close($con);
}
?>