Jump to content
TNG Community

Roger's File for Today's Birthdays


theKiwi

Recommended Posts

The following code will generate a list of people born on this day with their birth year and name. 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 the file as an attachment.

Roger

<?
//=====================================================
//   birthdays.php
//   Author: Jeff Grantham  genealogy.kb5wck.com
//   with additions for Privacy and linking by
//   Roger Moffat     http://roger.lisaandroger.com
//=====================================================

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 ) {
$query2 = @mysql_query("SELECT personID, lastname, firstname, gedcom, YEAR(birthdatetr) AS BirthYear FROM $people_table WHERE MONTH( birthdatetr ) = MONTH( CURDATE(  )  ) AND DAYOFMONTH(birthdatetr) = DAYOFMONTH(CURDATE()) ORDER BY BIRTHYEAR");
} else {
$query2 = @mysql_query("SELECT personID, lastname, firstname, gedcom, YEAR(birthdatetr) AS BirthYear FROM $people_table WHERE MONTH( birthdatetr ) = MONTH( CURDATE(  )  ) AND DAYOFMONTH(birthdatetr) = DAYOFMONTH(CURDATE()) AND $people_table.living = 0 ORDER BY BIRTHYEAR");
}

?>

<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">

<?
    while ($row = mysql_fetch_array($query2) ) {
            echo "<span class=\"smaller\"><a href=\"getperson.php?personID=" . $row["personID"] . "&tree=" . $row["gedcom"] . "\">" . $row["firstname"] . " " . $row["lastname"] . "</a> - <i>" . $row["BirthYear"] . "</i></span><br>";

        }

echo "</td></tr></table>";

//} else {
//  echo "<div align=\"center\"><span class=\"smaller\">Happy New Year.<br>No listings today.</span></div>";
//}
?>

todaybirthdays.php

Edited by theKiwi
Link to comment
Share on other sites

  • 1 month later...
  • Replies 81
  • Created
  • Last Reply

Top Posters In This Topic

  • theKiwi

    29

  • Torben

    5

  • Patti

    4

  • Luke

    4

Top Posters In This Topic

Newfloridian

You might like to consider the slight variations to the SQL query that I use.

Var 1. using birthdatetr the format of the date is yyyy-mm-dd. The date selection criteria avoids all misconstrued dates such as June 4th or 4-06 etc

Var 2. Our web site has six sections representing six different parts of the family tree. We use these anniversaries to show dates specific to the individuals in the section you are looking at. I have added the mySQL field branch to create these differential results.

$query2 = @mysql_query("SELECT lastname, firstname, personID, gedcom, branch, living, birthdatetr, YEAR(birthdatetr) AS BirthYear FROM tng_people WHERE (gedcom = 'Craxford1' AND (branch LIKE '%crax1%' or branch= '')) AND (MID(birthdatetr,9,2) = DATE_FORMAT(CURDATE(), '%d') AND MID(birthdatetr,6,2) = DATE_FORMAT(CURDATE(),'%m'))

ORDER BY BirthYear ASC");

ALSO note that the TNG mySQL tables use the field altbirthdatetr and not baptdatetr to record the baptism date

To see this in operation compare Page 1 in the RED section with that in TEAL or BROWN

Alan Craxford

The Craxford Family Genealogy Magazine

Link to comment
Share on other sites

And if anyone is curious how it might look in Coldfusion:

<h4><a href="calendar.cfm">Today's Birthdays</a> - <cfoutput>#dateFormat(now(),"Mmmm Dd")#</cfoutput></h4>

<cfquery name="getPeople" datasource="tng">select * from tng_people where day(birthdatetr) = #day(now())# and month(birthdatetr) = #month(now())# order by birthdatetr asc</cfquery>

<ul>

<cfoutput query="getPeople"><li>#dateFormat(birthdate,"yyyy")# - <a href="/family/genealogy/getperson.php?personID=#personID#&tree=mytree">#lastName#, <cfif living eq 0>#firstName#<cfelse>Living</cfif></a></li></cfoutput>

</ul>

Jerry Johnson

Link to comment
Share on other sites

  • 3 months later...

The following code will generate a list of people born on this day with their birth year and name. 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 the file as an attachment.

Roger

<?
//=====================================================
//   birthdays.php
//   Author: Jeff Grantham  genealogy.kb5wck.com
//   with additions for Privacy and linking by
//   Roger Moffat     http://roger.lisaandroger.com
//=====================================================

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 ) {
$query2 = @mysql_query("SELECT personID, lastname, firstname, gedcom, YEAR(birthdatetr) AS BirthYear FROM $people_table WHERE MONTH( birthdatetr ) = MONTH( CURDATE(  )  ) AND DAYOFMONTH(birthdatetr) = DAYOFMONTH(CURDATE()) ORDER BY BIRTHYEAR");
} else {
$query2 = @mysql_query("SELECT personID, lastname, firstname, gedcom, YEAR(birthdatetr) AS BirthYear FROM $people_table WHERE MONTH( birthdatetr ) = MONTH( CURDATE(  )  ) AND DAYOFMONTH(birthdatetr) = DAYOFMONTH(CURDATE()) AND $people_table.living = 0 ORDER BY BIRTHYEAR");
}

?>

<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">

<?
    while ($row = mysql_fetch_array($query2) ) {
            echo "<span class=\"smaller\"><a href=\"getperson.php?personID=" . $row["personID"] . "&tree=" . $row["gedcom"] . "\">" . $row["firstname"] . " " . $row["lastname"] . "</a> - <i>" . $row["BirthYear"] . "</i></span><br>";

        }

echo "</td></tr></table>";

//} else {
//  echo "<div align=\"center\"><span class=\"smaller\">Happy New Year.<br>No listings today.</span></div>";
//}
?>

todaybirthdays.php

Cool add-on :-P

Just now added it to my site.

Thanks!

Link to comment
Share on other sites

  • 2 months later...

so what could be the problem if it shows "no birthdays" and you know there's a birthday today? Thanks.

Is the person alive?

Does it make a difference if you log in to your site then view the page?

Roger

Link to comment
Share on other sites

No, the person isn't living. Here's his page: http://hobbits8.com/FamilyTree/getperson.p...66&tree=PLH

I wondered if it made a difference that I have day first and then month.

I don't have another birthday in my database until December 1st.

Thanks for the help, Roger. And thanks for creating the script.

Link to comment
Share on other sites

This page

http://hobbits8.com/FamilyTree/anniversari...tree=&page=

on your site correctly lists him as born 28 Nov, so TNG understands the date OK.

See what happens on 1 December.

Have there been days when the script did work OK, or has it always said No Birthdays Today?

Roger

Yesterday was the first day I added the script. I only just installed TNG the day before.

Link to comment
Share on other sites

I just upgraded my server to PHP 5.2.0 this afternoon, and in the aftermath of that discovered a problem in these files which prevented them working - under PHP 5.2.0 at least. The opening line was

<?

when it should have been

<?php

This incorrect line worked OK under PHP 4.x.x.

So here's an updated version of the file for those interested.

Note that this wouldn't have affected Patti's problem I don't think.

Roger

todaybirthdays.php

Link to comment
Share on other sites

See what happens on 1 December.

Roger

Hey, the date just turned over to December 1st and two birthdays are showing up! Thanks.

Link to comment
Share on other sites

  • 1 month later...

This is a great script.

Is there away to display the birthdates before the actual date? For example:

If I wanted to create a banner that displays family members birthdates 15 or 30 days prior to the actual date as a reminder so that family members have time to send greetings or flowers prior to the date?

Dylan :?:

Link to comment
Share on other sites

This is a great script.

Is there away to display the birthdates before the actual date? For example:

If I wanted to create a banner that displays family members birthdates 15 or 30 days prior to the actual date as a reminder so that family members have time to send greetings or flowers prior to the date?

Dylan :?:

I'm sure there is, but off hand I don't know what that would be.

Roger

Link to comment
Share on other sites

This is a great script.

Is there away to display the birthdates before the actual date? For example:

I have a script that will email you birthdays 'x' days in advance here

You're more than welcome to use whatever parts of it to display future birthdays.

Rush

Link to comment
Share on other sites

This is a great script.

Is there away to display the birthdates before the actual date? For example:

If I wanted to create a banner that displays family members birthdates 15 or 30 days prior to the actual date as a reminder so that family members have time to send greetings or flowers prior to the date?

Dylan :?:

THANK YOU RUSH!!!!!!

OK I have page working that will list the people who are having a birthday x days in advance, where you can specify x

where are you going to show this? By its nature, you only want it to show living people, unless you send greetings to the departed? <g>.

Will it need to test if the user is logged in to see the output?

The file attached here finds only living people, AND it only shows them to people logged in.

Cheers

Roger

advancebirthdays.php

Link to comment
Share on other sites

You're quite welcome Roger...figured there was no need to duplicate effort if the code would work for ya ;)

Rush

Perhaps I messed things up in changing the text that describes the birthdays coming up, but I have run into a problem that I can't figure out. If I set the advance days to 15, I get one person listed with the correct birthday. If I change the advance days to 30, I get no names listed. Shouldn't the name that was displayed with 15 days also be displayed if I show 30 days? This pulls the name of birthdays in the future does it not? Am I misunderstanding the purpose of the script?

Thanks.

Link to comment
Share on other sites

Perhaps I messed things up in changing the text that describes the birthdays coming up, but I have run into a problem that I can't figure out. If I set the advance days to 15, I get one person listed with the correct birthday. If I change the advance days to 30, I get no names listed. Shouldn't the name that was displayed with 15 days also be displayed if I show 30 days? This pulls the name of birthdays in the future does it not? Am I misunderstanding the purpose of the script?

No, it's not getting all the names for the next 30 days, it's getting the names that are for 30 days from now.

Rush's code was designed to send out one eMail, x days in advance, not an eMail a day for the next x days.

It's likely possible to do what you want, but I don't know just what to change in the code to achieve that.

Roger

Link to comment
Share on other sites

This should get all the birthdays coming up from now to the next 'x' amount of days:

$bdquery= "SELECT lastname, firstname, birthdatetr, birthdate, personID, gedcom, living FROM `tng_people` WHERE RIGHT( `birthdatetr` , 5 ) >= RIGHT(CURDATE( ) , 5) AND RIGHT( DATE_ADD( CURDATE( ), INTERVAL '$futuredays' DAY ) , 5 ) >= RIGHT( `birthdatetr` , 5 ) AND living = 1 AND RIGHT (`birthdatetr` , 2) NOT LIKE '00'";

Might be ugly, but pretty sure it should work.

Rush

Link to comment
Share on other sites

This should get all the birthdays coming up from now to the next 'x' amount of days:

$bdquery= "SELECT lastname, firstname, birthdatetr, birthdate, personID, gedcom, living FROM `tng_people` WHERE RIGHT( `birthdatetr` , 5 ) >= RIGHT(CURDATE( ) , 5) AND RIGHT( DATE_ADD( CURDATE( ), INTERVAL '$futuredays' DAY ) , 5 ) >= RIGHT( `birthdatetr` , 5 ) AND living = 1 AND RIGHT (`birthdatetr` , 2) NOT LIKE '00'";

Might be ugly, but pretty sure it should work.

Thanks Rush

Here's a new revised file that finds all the birthdays coming up in the next x days and sorts them into order by the day and month.

Cheers

Roger

advancebirthdays.php

Link to comment
Share on other sites

  • 1 month later...
Doug_in_Maine

I brought down your php code, modified it to access my database, and then tested it. It ran beautifully and I was shown the names of two people who had birthdays today.

I thought that it would then be a simple task to put the code into my home page which is an HTML file. I chose a spot where I wanted the code to be, and inserted it. But when I uploaded and ran the test page, my results were as follows:

No Birthdays Today"; } else { while ($row = mysql_fetch_array($query2) ) { echo "" . $row["firstname"] . " " . $row["lastname"] . " - " . $row["BirthYear"] . "

"; } } echo "

"; ?>

Any thoughts about what I did wrong?

Link to comment
Share on other sites

I brought down your php code, modified it to access my database, and then tested it. It ran beautifully and I was shown the names of two people who had birthdays today.

I thought that it would then be a simple task to put the code into my home page which is an HTML file. I chose a spot where I wanted the code to be, and inserted it. But when I uploaded and ran the test page, my results were as follows:

No Birthdays Today"; } else { while ($row = mysql_fetch_array($query2) ) { echo "" . $row["firstname"] . " " . $row["lastname"] . " - " . $row["BirthYear"] . "

"; } } echo "

"; ?>

Any thoughts about what I did wrong?

It needs to go into a php page.

so you need to change your index.html page to be an index.php page, then the php code will get executed (it's done by the server based on the file name extension being php) and you'll see the results you expect.

Roger

Link to comment
Share on other sites

  • 4 weeks later...
clarkkent93

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

John Doe - 2005 (2)

Link to comment
Share on other sites

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

John Doe - 2005 (2)

'

It's not exactly clear to me what you're asking - are you wanting to know how long ago something happened?

Is that helpful to know that a birth in 1631 was 376 years ago, or that a marriage in 1803 was 204 years ago?

But assuming that's what you want, change line 31 of todaybirthdays.php to these 2 lines..

    $ago=date('Y')-$row["BirthYear"];
        echo "<span class=\"smaller\"><a href=\"getperson.php?personID=" . $row["personID"] . "&tree=" . $row["gedcom"] . "\">" . $row["firstname"] . " " . $row["lastname"] . "</a> - <i>" . $row["BirthYear"] . " (" . $ago . ")" . "</i></span><br>";

will do it for you. Make similar changes in the other files should work.

Roger

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...