theKiwi Posted April 27, 2006 Report Share Posted April 27, 2006 (edited) 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 April 29, 2006 by theKiwi Quote Link to comment Share on other sites More sharing options...
Newfloridian Posted June 6, 2006 Report Share Posted June 6, 2006 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 etcVar 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 dateTo see this in operation compare Page 1 in the RED section with that in TEAL or BROWNAlan CraxfordThe Craxford Family Genealogy Magazine Quote Link to comment Share on other sites More sharing options...
Jerry Posted June 8, 2006 Report Share Posted June 8, 2006 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 Quote Link to comment Share on other sites More sharing options...
beun.net Posted September 12, 2006 Report Share Posted September 12, 2006 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.phpCool add-on Just now added it to my site.Thanks! Quote Link to comment Share on other sites More sharing options...
theKiwi Posted September 13, 2006 Author Report Share Posted September 13, 2006 I've updated this file a little bit to show "No Birthdays Today" if there are no birthdays today.todaybirthdays.php Quote Link to comment Share on other sites More sharing options...
Patti Posted November 29, 2006 Report Share Posted November 29, 2006 so what could be the problem if it shows "no birthdays" and you know there's a birthday today? Thanks. Quote Link to comment Share on other sites More sharing options...
theKiwi Posted November 29, 2006 Author Report Share Posted November 29, 2006 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 Quote Link to comment Share on other sites More sharing options...
Patti Posted November 29, 2006 Report Share Posted November 29, 2006 No, the person isn't living. Here's his page: http://hobbits8.com/FamilyTree/getperson.p...66&tree=PLHI 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. Quote Link to comment Share on other sites More sharing options...
theKiwi Posted November 29, 2006 Author Report Share Posted November 29, 2006 This pagehttp://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 Quote Link to comment Share on other sites More sharing options...
Patti Posted November 29, 2006 Report Share Posted November 29, 2006 This pagehttp://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?RogerYesterday was the first day I added the script. I only just installed TNG the day before. Quote Link to comment Share on other sites More sharing options...
theKiwi Posted November 29, 2006 Author Report Share Posted November 29, 2006 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<?phpThis 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.Rogertodaybirthdays.php Quote Link to comment Share on other sites More sharing options...
Patti Posted December 1, 2006 Report Share Posted December 1, 2006 See what happens on 1 December.RogerHey, the date just turned over to December 1st and two birthdays are showing up! Thanks. Quote Link to comment Share on other sites More sharing options...
dkiner Posted January 25, 2007 Report Share Posted January 25, 2007 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 : Quote Link to comment Share on other sites More sharing options...
theKiwi Posted January 25, 2007 Author Report Share Posted January 25, 2007 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 Quote Link to comment Share on other sites More sharing options...
Rush Posted January 25, 2007 Report Share Posted January 25, 2007 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 hereYou're more than welcome to use whatever parts of it to display future birthdays.Rush Quote Link to comment Share on other sites More sharing options...
theKiwi Posted January 25, 2007 Author Report Share Posted January 25, 2007 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 xwhere 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.CheersRogeradvancebirthdays.php Quote Link to comment Share on other sites More sharing options...
Rush Posted January 25, 2007 Report Share Posted January 25, 2007 You're quite welcome Roger...figured there was no need to duplicate effort if the code would work for ya Rush Quote Link to comment Share on other sites More sharing options...
afoster Posted January 26, 2007 Report Share Posted January 26, 2007 You're quite welcome Roger...figured there was no need to duplicate effort if the code would work for ya RushPerhaps 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. Quote Link to comment Share on other sites More sharing options...
theKiwi Posted January 26, 2007 Author Report Share Posted January 26, 2007 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 Quote Link to comment Share on other sites More sharing options...
Rush Posted January 26, 2007 Report Share Posted January 26, 2007 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 Quote Link to comment Share on other sites More sharing options...
theKiwi Posted January 26, 2007 Author Report Share Posted January 26, 2007 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 RushHere'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.CheersRogeradvancebirthdays.php Quote Link to comment Share on other sites More sharing options...
Doug_in_Maine Posted March 25, 2007 Report Share Posted March 25, 2007 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? Quote Link to comment Share on other sites More sharing options...
theKiwi Posted March 25, 2007 Author Report Share Posted March 25, 2007 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 Quote Link to comment Share on other sites More sharing options...
clarkkent93 Posted April 21, 2007 Report Share Posted April 21, 2007 Would it be possible to have the number of years right after the name and date? Example: John Doe - 2005 (2) Quote Link to comment Share on other sites More sharing options...
theKiwi Posted April 22, 2007 Author Report Share Posted April 22, 2007 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.