IPB
IPB

Welcome Guest ( Log In | Register )

4 Pages V  1 2 3 > »   
Reply to this topicStart new topic
> Roger's File for Today's Birthdays, The code I use to generate a list of people born today.
theKiwi
post Apr 27 2006, 10:16 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 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

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


This post has been edited by theKiwi: Apr 29 2006, 05:22 AM
User is online!Profile CardPM
Go to the top of the page
+Quote Post
Newfloridian
post Jun 6 2006, 12:35 PM
Post #2


Advanced Member


Group: Members
Posts: 46
Joined: 26-February 05
From: UK
Member No.: 440



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


Advanced Member


Group: Members
Posts: 67
Joined: 24-May 06
From: Boston
Member No.: 1,070



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
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
beun.net
post Sep 12 2006, 03:49 AM
Post #4


Advanced Member


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



QUOTE(theKiwi @ Apr 27 2006, 06:16 PM) *

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

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



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

Just now added it to my site.
Thanks!
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
theKiwi
post Sep 13 2006, 07:28 AM
Post #5


Advanced Member


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



I've updated this file a little bit to show "No Birthdays Today" if there are no birthdays today.


Attached File(s)
Attached File  todaybirthdays.php ( 1.52k ) Number of downloads: 319
User is online!Profile CardPM
Go to the top of the page
+Quote Post
Patti
post Nov 28 2006, 09:35 PM
Post #6


Advanced Member


Group: Members
Posts: 45
Joined: 27-November 06
From: Clever, Missouri
Member No.: 1,650



so what could be the problem if it shows "no birthdays" and you know there's a birthday today? Thanks.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
theKiwi
post Nov 28 2006, 09:52 PM
Post #7


Advanced Member


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



QUOTE(Patti @ Nov 28 2006, 10:35 PM) *

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
User is online!Profile CardPM
Go to the top of the page
+Quote Post
Patti
post Nov 29 2006, 02:05 PM
Post #8


Advanced Member


Group: Members
Posts: 45
Joined: 27-November 06
From: Clever, Missouri
Member No.: 1,650



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


Advanced Member


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



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
User is online!Profile CardPM
Go to the top of the page
+Quote Post
Patti
post Nov 29 2006, 04:08 PM
Post #10


Advanced Member


Group: Members
Posts: 45
Joined: 27-November 06
From: Clever, Missouri
Member No.: 1,650



QUOTE(theKiwi @ Nov 29 2006, 02:27 PM) *

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


Advanced Member


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



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

Attached File  todaybirthdays.php ( 1.49k ) Number of downloads: 289
User is online!Profile CardPM
Go to the top of the page
+Quote Post
Patti
post Dec 1 2006, 12:17 AM
Post #12


Advanced Member


Group: Members
Posts: 45
Joined: 27-November 06
From: Clever, Missouri
Member No.: 1,650



QUOTE(theKiwi @ Nov 29 2006, 02:27 PM) *



See what happens on 1 December.


Roger


Hey, the date just turned over to December 1st and two birthdays are showing up! Thanks.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
dkiner
post Jan 25 2007, 07:27 AM
Post #13


Newbie


Group: Members
Posts: 1
Joined: 27-December 06
Member No.: 1,844



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 (IMG:style_emoticons/default/icon_question.gif)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
theKiwi
post Jan 25 2007, 09:54 AM
Post #14


Advanced Member


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



QUOTE(dkiner @ Jan 25 2007, 08:27 AM) *

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



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

Roger
User is online!Profile CardPM
Go to the top of the page
+Quote Post
Rush
post Jan 25 2007, 10:25 AM
Post #15


Advanced Member


Group: Members
Posts: 1,008
Joined: 8-November 05
Member No.: 676



QUOTE(dkiner @ Jan 25 2007, 08:27 AM) *

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



User is online!Profile CardPM
Go to the top of the page
+Quote Post
theKiwi
post Jan 25 2007, 12:47 PM
Post #16


Advanced Member


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



QUOTE(dkiner @ Jan 25 2007, 08:27 AM) *

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


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



Attached File(s)
Attached File  advancebirthdays.php ( 1.52k ) Number of downloads: 174
User is online!Profile CardPM
Go to the top of the page
+Quote Post
Rush
post Jan 25 2007, 04:40 PM
Post #17


Advanced Member


Group: Members
Posts: 1,008
Joined: 8-November 05
Member No.: 676



You're quite welcome Roger...figured there was no need to duplicate effort if the code would work for ya (IMG:style_emoticons/default/icon_wink.gif)

Rush
User is online!Profile CardPM
Go to the top of the page
+Quote Post
afoster
post Jan 25 2007, 10:25 PM
Post #18


Advanced Member


Group: Members
Posts: 43
Joined: 11-November 05
Member No.: 681



QUOTE(Rush @ Jan 25 2007, 02:40 PM) *

You're quite welcome Roger...figured there was no need to duplicate effort if the code would work for ya (IMG:style_emoticons/default/icon_wink.gif)

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.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
theKiwi
post Jan 25 2007, 11:01 PM
Post #19


Advanced Member


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



QUOTE(afoster @ Jan 25 2007, 11:25 PM) *

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
User is online!Profile CardPM
Go to the top of the page
+Quote Post
Rush
post Jan 25 2007, 11:54 PM
Post #20


Advanced Member


Group: Members
Posts: 1,008
Joined: 8-November 05
Member No.: 676



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


User is online!Profile CardPM
Go to the top of the page
+Quote Post

4 Pages V  1 2 3 > » 
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:07 AM