![]() ![]() |
| theKiwi |
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>"; //} ?>
todaybirthdays.php ( 1.55k )
Number of downloads: 405This post has been edited by theKiwi: Apr 29 2006, 05:22 AM |
| Newfloridian |
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 |
| Jerry |
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 |
| beun.net |
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 |
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>"; //} ?>
todaybirthdays.php ( 1.55k )
Number of downloads: 405Cool add-on (IMG:style_emoticons/default/icon_razz.gif) Just now added it to my site. Thanks! |
| theKiwi |
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)
todaybirthdays.php ( 1.52k )
Number of downloads: 319 |
| Patti |
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.
|
| theKiwi |
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 |
|
| Patti |
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. |
| theKiwi |
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 |
| Patti |
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 |
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. |
| theKiwi |
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
todaybirthdays.php ( 1.49k )
Number of downloads: 289 |
| Patti |
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 |
|
| dkiner |
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) |
| theKiwi |
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 |
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 |
| Rush |
Jan 25 2007, 10:25 AM
Post
#15
|
|
Advanced Member Group: Members Posts: 1,008 Joined: 8-November 05 Member No.: 676 |
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 |
| theKiwi |
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 |
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)
advancebirthdays.php ( 1.52k )
Number of downloads: 174 |
| Rush |
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 |
| afoster |
Jan 25 2007, 10:25 PM
Post
#18
|
|
Advanced Member Group: Members Posts: 43 Joined: 11-November 05 Member No.: 681 |
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. |
| theKiwi |
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 |
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 |
| Rush |
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 |
![]() ![]() |
|
Lo-Fi Version | Time is now: 3rd September 2010 - 05:07 AM |