Jump to content
TNG Community

Roger's File for Today's Anniversaries


theKiwi

Recommended Posts

The following code will generate a list of people married on this day with their marriage year and names. The name is a link to their page. If you are not logged in it doesn't show the Living people.

The lines that are currently commented out (after the lines at the head) I put there to suppress generating the list on New Year's day since anyone who had only a year for their date was assumed to be on 1 January, so the lists were impossibly long and the server load quite high. I don't now remember why they are commented out though.

PS I've now added this file as an attachment.

Roger

<?
//=====================================================
//   anniv.php - working copy
//   borrowed form the php-nuke 1.6 module
//   Authors: Jeff Grantham  genealogy.kb5wck.com
//            Roger Moffat [url=http://roger.lisaandroger.com]http://roger.lisaandroger.com[/url]
//=====================================================

include_once("config.php");
include_once("genlib.php");

tng_db_connect($database_host, $database_name,$database_username,$database_password) or exit;


//$today = date("m/d");

//if ($today != "01/01") {

if( $currentuser ) {

$tngquery = @mysql_query("SELECT husband, wife, marrdatetr, gedcom, familyID FROM $families_table where DAYOFMONTH(marrdatetr) = DAYOFMONTH(CURDATE()) and MONTH(marrdatetr) = MONTH(CURDATE()) ORDER BY marrdatetr");

    while( $dbrow = mysql_fetch_assoc( $tngquery ) ) {
       if( $dbrow[husband] && $dbrow[wife] ) {
    $tngqueryh = @mysql_query("SELECT lastname, firstname, personID, gedcom, living from $people_table where personID = \"$dbrow[husband]\" and gedcom = \"$dbrow[gedcom]\"");
    $foundh = mysql_num_rows( $tngqueryh );
       if( $foundh == 1 )
              $dbrowh = mysql_fetch_array( $tngqueryh );
             $tngqueryw = @mysql_query("SELECT lastname, firstname, personID, living from $people_table where personID = \"$dbrow[wife]\" and gedcom = \"$dbrow[gedcom]\"");
          $foundw = mysql_num_rows( $tngqueryw );
             if( $foundw == 1 )
            $dbroww = mysql_fetch_array( $tngqueryw );
               $content .= "<span class=\"smaller\"><a  href=\"$cms[url]/familygroup.php?familyID=$dbrow[familyID]&tree=$dbrow[gedcom]\">";
                    
            $content .= "$dbrowh[firstname] $dbrowh[lastname] married ";
            $content .= "$dbroww[firstname] $dbroww[lastname]</a> - <i>" . substr( $dbrow[marrdatetr], 0, 4 ) ."</i></span><br>\n";
}
    }
echo $content;
}else{

$tngquery = @mysql_query("SELECT husband, wife, marrdatetr, gedcom, familyID FROM $families_table where DAYOFMONTH(marrdatetr) = DAYOFMONTH(CURDATE()) and MONTH(marrdatetr) = MONTH(CURDATE()) and living = 0 ORDER BY marrdatetr");

    while( $dbrow = mysql_fetch_assoc( $tngquery ) ) {
       if( $dbrow[husband] && $dbrow[wife] ) {
    $tngqueryh = @mysql_query("SELECT lastname, firstname, personID, gedcom, living from $people_table where personID = \"$dbrow[husband]\" and gedcom = \"$dbrow[gedcom]\"");
    $foundh = mysql_num_rows( $tngqueryh );
       if( $foundh == 1 )
              $dbrowh = mysql_fetch_array( $tngqueryh );
             $tngqueryw = @mysql_query("SELECT lastname, firstname, personID, living from $people_table where personID = \"$dbrow[wife]\" and gedcom = \"$dbrow[gedcom]\"");
          $foundw = mysql_num_rows( $tngqueryw );
             if( $foundw == 1 )
            $dbroww = mysql_fetch_array( $tngqueryw );
               $content .= "<span class=\"smaller\"><a  href=\"$cms[url]/familygroup.php?familyID=$dbrow[familyID]&tree=$dbrow[gedcom]\">";
                    
            $content .= "$dbrowh[firstname] $dbrowh[lastname] married ";
            $content .= "$dbroww[firstname] $dbroww[lastname]</a> - <i>" . substr( $dbrow[marrdatetr], 0, 4 ) ."</i></span><br>\n";
}
    }
echo $content;
   }
//} else {
//  echo "<div align=\"center\"><span class=\"smaller\">Happy New Year.<br>No listings today.</span></div>";
// }
?>

todayanniversaries.php

Edited by theKiwi
Link to comment
Share on other sites

  • 1 month later...

Hi Roger,

First off thanks for sharing the codes.

I've downloaded and installed all 3 files(Birthday, Death, Anniversaries) the same way, todaybirthdays.php is the only one that returns results. Even though there is an anniversary today.

Any Thoughts?

Lee

Link to comment
Share on other sites

Are both of the people in the Anniversaries not living?

If either of them is living then it will return no results.

Roger

Link to comment
Share on other sites

Are both of the people in the Anniversaries not living?

If either of them is living then it will return no results.

Roger

Yes, they are living. Can the code be modified to show the living if the user has rights?

Lee

Link to comment
Share on other sites

It already does that I think - the

if( $currentuser ) {

line in the code is checking for that - if you log in, then view the index page it should show it to you.

Roger

Link to comment
Share on other sites

  • 3 months later...

Cool add-on :-P

Just now added it to my site.

Thanks!

But... I do have a question.

If on a specific date there is no anniversary, the above PHP-file doesn't display anything.

Would it be possible to have it state "No anniversaries today", or something like that, when there is no anniversary?

That would rule.

Link to comment
Share on other sites

But... I do have a question.

If on a specific date there is no anniversary, the above PHP-file doesn't display anything.

Would it be possible to have it state "No anniversaries today", or something like that, when there is no anniversary?

That would rule.

OK - not that I really know what I'm doing, but after some trial and error I think it's working. See the attached file.

If anyone has a better way of finding out if the result set is empty or not I'm all eyes.

Roger

todayanniversaries.php

Link to comment
Share on other sites

OK - not that I really know what I'm doing,

Yeah, right ;-)

but after some trial and error I think it's working. See the attached file.

If anyone has a better way of finding out if the result set is empty or not I'm all eyes.

Roger

Thanks man!

I'm gonna check it now :)

//edit: Seems to work like a charm. Thanks!

Link to comment
Share on other sites

  • 2 months later...

Here's an updated file that works under PHP 5.2.0. The previous version started with

<?

which worked with PHP 4.x.x, but wouldn't work with PHP 5.2.0. This file starts with

<?php

Cheers

Roger

todayanniversaries.php

I think you will find that the above issue is not a PHP version problem. This is simply a php configuration choice. The <? tag is the short open tag syntax.

The short open tag can be configured to work in both of the versions mentioned above. Edit your php.ini file and set short_open_tags=on

Of course, using the <?php is the more portable option to start with.

Brian

Link to comment
Share on other sites

I think you will find that the above issue is not a PHP version problem. This is simply a php configuration choice. The <? tag is the short open tag syntax.

The short open tag can be configured to work in both of the versions mentioned above. Edit your php.ini file and set short_open_tags=on

Of course, using the <?php is the more portable option to start with.

Thanks for the explanation Brian...

I got a new php.ini file with the PHP 5.2.0 installation - the installer on Mac OS X put it in parallel with PHP 4.4.4, so I can without much trouble switch between the versions should the need ever arise.

I just figured it had to be something with the new PHP, and when <? phpinfo(); ?> wouldn't work, I eventually tripped over the reason.

As my php.ini file notes now that I've looked in there for this it's best to use <?php when you don't control the server yourself.

Cheers

Roger

Link to comment
Share on other sites

  • 4 months later...
clarkkent93

Would it be possible to have the number of years right after the names and date? Example:

John Doe & Bessie - 2005 (2)

Link to comment
Share on other sites

  • 4 months later...

Hi Roger,

I just uploaded your Birthday, Anniversary and Deaths scripts. I love them on the front page of the website! I do have one question I'd like to see if you can implement into the Anniversaries script. Does someone who has been divorced still show up in the Anniversary script, or are they not shown? I've only had the script up a few days and haven't had a chance to see if they show up. It would be sensitive to people's feelings if a divorced couple doesn't show up, but I don't know how easy or difficult it would be to have that happen.

Thanks for your time!

Link to comment
Share on other sites

This script only examines the date of the wedding, and nothing else. What happens to a couple after the wedding isn't considered by the script.

Since that script isn't mine alone - it's based on someone else's work too, I don't entirely know what's happening and I don't know how hard it would be to check if the couple was divorced afterwards or not.

The only hopeful thought is that someone who is in your database and divorced, wouldn't necessarily be very excited about looking at your site on the day the fateful marriage commenced <g>

Roger

Link to comment
Share on other sites

Well I guess this would never happen on my site as I do not display information about living people...

Besides the wedding event happend regardless of the outcome...

It is a bit like trying to hide the fact that a child was born out of wedlock. The event happended regardless of the emotional attachment the event may have...

I firmly believe in documenting as best I can the events that have taken place in my ancestors lives and it is when someone goes to great lengths to obfuscate these events that it make it difficult for me to uncover the real event and not the emotional cover-up or whitewash...

Link to comment
Share on other sites

I wasn't trying "hide" anything. The divorced spouses still show up on an individual's page. I look upon the Anniversaries on my front page as a way to "celebrate" an anniversary, if you will, and wanted to be sensitive to those registered users (since a registered user can view the living's Anniversaries) who had a distasteful divorce. Plus, it all shows up anyway in Darren's anniversaries.php script for registered users.

Anyway, I solved the problem myself with a little trial and error.

There are 2 queries in the code that need a slight addition. I added the phrase

and divdate = '' (2 single quotes) as you can see below.

$tngquery = @mysql_query("SELECT husband, wife, marrdatetr, gedcom, familyID FROM $families_table where DAYOFMONTH(marrdatetr) = DAYOFMONTH(CURDATE()) and MONTH(marrdatetr) = MONTH(CURDATE()) and divdate = '' ORDER BY marrdatetr");

Do the same on the other $tngquery (not the $tngqueryh or $tngqueryw).

I use Legacy, so I am assuming other gen programs use the same "divdate". Check your Families table to find out. When I mark marriage status as Divorced in Legacy, a "Y" shows up in my TNG database under divdate, not status, in the Families table, while a marriage with no divorce noted the divdate is blank. I've not marked any marriages in Legacy with a status of Annulled, Separated, etc., so I don't know exactly where those get put in the database. Maybe they are what show up in the "status" field in the Families table. That's for someone else to figure out!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...