IPB
IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Roger's File for Today's Anniversaries, The code I use to generate a list of people married today.
theKiwi
post Apr 27 2006, 10:26 AM
Post #1


Advanced Member


Group: Administrators
Posts: 1,799
Joined: 20-February 03
From: Caledonia, Michigan, USA
Member No.: 67



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

CODE
<?
//=====================================================
//   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>";
// }
?>
Attached File  todayanniversaries.php ( 3.17k ) Number of downloads: 291


This post has been edited by theKiwi: Apr 29 2006, 05:19 AM
User is online!Profile CardPM
Go to the top of the page
+Quote Post
clweed
post Jun 3 2006, 08:11 AM
Post #2


Advanced Member


Group: Members
Posts: 87
Joined: 14-January 06
From: Friendswood, Texas
Member No.: 759



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
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
theKiwi
post Jun 3 2006, 03:39 PM
Post #3


Advanced Member


Group: Administrators
Posts: 1,799
Joined: 20-February 03
From: Caledonia, Michigan, USA
Member No.: 67



Are both of the people in the Anniversaries not living?

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

Roger
User is online!Profile CardPM
Go to the top of the page
+Quote Post
clweed
post Jun 3 2006, 04:20 PM
Post #4


Advanced Member


Group: Members
Posts: 87
Joined: 14-January 06
From: Friendswood, Texas
Member No.: 759



QUOTE(theKiwi @ Jun 3 2006, 04:39 PM) *

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
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
theKiwi
post Jun 3 2006, 09:52 PM
Post #5


Advanced Member


Group: Administrators
Posts: 1,799
Joined: 20-February 03
From: Caledonia, Michigan, USA
Member No.: 67



It already does that I think - the
CODE
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
User is online!Profile CardPM
Go to the top of the page
+Quote Post
beun.net
post Sep 12 2006, 04:05 AM
Post #6


Advanced Member


Group: Members
Posts: 91
Joined: 31-August 06
From: The Netherlands
Member No.: 1,312



Cool add-on (IMG:style_emoticons/default/icon_razz.gif)

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.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
theKiwi
post Sep 12 2006, 07:35 AM
Post #7


Advanced Member


Group: Administrators
Posts: 1,799
Joined: 20-February 03
From: Caledonia, Michigan, USA
Member No.: 67



QUOTE(beun.net @ Sep 12 2006, 06:05 AM) *

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


Attached File(s)
Attached File  todayanniversaries.php ( 3.39k ) Number of downloads: 179
User is online!Profile CardPM
Go to the top of the page
+Quote Post
beun.net
post Sep 12 2006, 07:51 AM
Post #8


Advanced Member


Group: Members
Posts: 91
Joined: 31-August 06
From: The Netherlands
Member No.: 1,312



QUOTE(theKiwi @ Sep 12 2006, 03:35 PM) *

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

Yeah, right (IMG:style_emoticons/default/icon_wink.gif)

QUOTE
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 (IMG:style_emoticons/default/icon_smile.gif)


//edit: Seems to work like a charm. Thanks!
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
theKiwi
post Nov 29 2006, 05:20 PM
Post #9


Advanced Member


Group: Administrators
Posts: 1,799
Joined: 20-February 03
From: Caledonia, Michigan, USA
Member No.: 67



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

Attached File  todayanniversaries.php ( 3.41k ) Number of downloads: 246
User is online!Profile CardPM
Go to the top of the page
+Quote Post
B McFadyen
post Nov 29 2006, 08:10 PM
Post #10


Advanced Member


Group: Members
Posts: 99
Joined: 19-May 06
From: Burlington, Ontario, Canada
Member No.: 1,060



QUOTE(theKiwi @ Nov 29 2006, 06:20 PM) *

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

Attached File  todayanniversaries.php ( 3.41k ) Number of downloads: 246



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
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
theKiwi
post Nov 29 2006, 08:55 PM
Post #11


Advanced Member


Group: Administrators
Posts: 1,799
Joined: 20-February 03
From: Caledonia, Michigan, USA
Member No.: 67



QUOTE(B McFadyen @ Nov 29 2006, 09:10 PM) *

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
User is online!Profile CardPM
Go to the top of the page
+Quote Post
clarkkent93
post Apr 21 2007, 11:09 AM
Post #12


Advanced Member


Group: Members
Posts: 53
Joined: 2-April 07
From: Missoula, MT
Member No.: 2,722



Would it be possible to have the number of years right after the names and date? Example:
John Doe & Bessie - 2005 (2)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Scattered
post Aug 26 2007, 12:58 PM
Post #13


Newbie


Group: Members
Posts: 9
Joined: 8-March 06
From: Utah
Member No.: 877



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!
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
theKiwi
post Aug 26 2007, 02:31 PM
Post #14


Advanced Member


Group: Administrators
Posts: 1,799
Joined: 20-February 03
From: Caledonia, Michigan, USA
Member No.: 67



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
User is online!Profile CardPM
Go to the top of the page
+Quote Post
genfan
post Aug 27 2007, 10:49 AM
Post #15


Advanced Member


Group: Members
Posts: 132
Joined: 3-March 06
From: Deleware
Member No.: 871



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...
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Scattered
post Aug 28 2007, 10:00 AM
Post #16


Newbie


Group: Members
Posts: 9
Joined: 8-March 06
From: Utah
Member No.: 877



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!




User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 3rd September 2010 - 05:06 AM