Would it be possible to get birthdays from user data and post Happy Birthday to that user(s) in a block
Example:
Happy Birthday:
(User Names)
Contact technodragon73 he mentioned today that he had a mod installed that displayed a message on a users birthday
I got it working using ssi, but what I want is only to display "todays birthdays"
can you let us all know what you did in the ssi as I would like to see what it does
In a phpbox I added -- ssi_todaysBirthdays();
This seems to display all birthdays for the month, I would like to display birthdays only for that day.
cool thanks.
I think the time period displayed is related to the calendar settings for the front page of the forum. Try setting it at 1 day, and see if that will only show birthdays for that day.
gerrymo,
Perfect, that is all I needed to do. Now it is displaying only todays birthdays.
Thanks a million
Heres a way.. (allways make backups ;))
Open Sources/Load.php
Find:
$user_info['groups'] = array_unique($user_info['groups']);
Add After:
if (isset($user_settings['birthdate']))
{
$cur_date = getdate(forum_time());
$user_info['today_is_birthday'] = $cur_date['mon'] == substr($user_settings['birthdate'], 5, 2) && $cur_date['mday'] == substr($user_settings['birthdate'], 8);
}
Search For:
'email' => &$user_info['email']
Replace With:
'email' => &$user_info['email'],
'today_is_birthday' => &$user_info['today_is_birthday'],
Open Themes/Default/TPortalBlocks.template.php
Find:
echo '<span class="normaltext">
', $txt['hello_member'], ' <b>', $context['user']['name'], '</b></span>';
Replace With
if ($context['user']['today_is_birthday'])
echo '
<span class="normaltext"><b>Happy Birthday ', $context['user']['name'], '</b></span>';
else
echo '
<span class="normaltext">', $txt['hello_member'], ' <b>', $context['user']['name'], '</b></span>';
it will show on the user block.
Thanks OnTap! Nice Snippet
hi, i added this snippet and nothing looks different. could you explain what this snippet is supposed to do? thanks!
Quote from: jpark on May 08, 2006, 01:50:48 AM
hi, i added this snippet and nothing looks different. could you explain what this snippet is supposed to do? thanks!
on the userblock where it says "hey, jpark"..
it will change "Happy Birthday jpark" on the day of your birthday.
ahh i see~ thank you :D
Any screenshot of this block ?
Thanks a bunch ! :)
I also installed the block and set Calendar settings to 30 days. In this case, all the birthdays within a 30-days window are displayed. But I'd like to display the birthdays for the current month e.g. August. How can I do this?
Knowing that there will be more tweaks asked for ;)....
Put the following in a phpbox:
global $db_prefix, $scripturl;
$title = date('F') . ' Birthdays';
echo '
<div class="tborder" style="margin-bottom: 5px;">
<div class="catbg2" style="padding: 4px; font-weight: bold;">';
echo $title;
echo '
</div>
<div class="windowbg" style="padding: 4px; ">';
$month_number = '-' . date('m') . '-';
$query = db_query(
"SELECT ID_MEMBER, memberName
FROM {$db_prefix}members
WHERE birthdate LIKE '%$month_number%'
AND birthdate NOT LIKE '0001-01-01'
ORDER BY memberName", __FILE__, __LINE__);
if(db_affected_rows() != 0)
{
while ($row = mysql_fetch_assoc($query))
{
echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['memberName'] . '</a><br />';
}
}
else
echo 'No birthdays this month';
echo' </div>
</div> ';
For it to look best set
Do not use title/frame
and
Do not allow block to collapse
This gives all the members with birthdays within the current month and lists them in alphabetical order by the member name.
Great, this works nice, thanks for your help.
QuoteKnowing that there will be more tweaks asked for Wink....
You know that I'd ask how to display the birthdates rather than the age near member name, don't you?
How do you want it? Something like:
Curly -- 8
Eloise -- 25
Fred -- 5
Larry -- 3
Moe -- 5
Wilma -- 10
or more like
3 -- Larry
5 -- Fred
5 -- Moe
8 -- Curly
10 -- Wilma
25 -- Eloise
The first one's easier but I think I can do the second. It all comes in the sorting.
I'd prefer this format:
Apollo (08.08)
Starbuck (12.08)
Adama (23.08)
Boomer (24.08)
Just add an "ORDER BY day ASC" to your query, then a while loop should do the job :)
Not exactly. The way the database is set up, the birthdate is in the format of yyyy-mm-dd, so if I order by birthdate, I'll get them ordered by the year they were born, not the day. It'll take a little more to order by day. I'll go play around with it for a bit.
Okay. I think this will do what you want:
global $db_prefix, $scripturl;
$title = date('F') . ' Birthdays';
echo '
<div class="tborder" style="margin-bottom: 5px;">
<div class="catbg2" style="padding: 4px; font-weight: bold;">';
echo $title;
echo '
</div>
<div class="windowbg" style="padding: 4px; ">';
$month = date('m');
$month_number = '-' . $month . '-';
$query = db_query(
"SELECT ID_MEMBER, memberName, birthdate
FROM {$db_prefix}members
WHERE birthdate LIKE '%$month_number%'
AND birthdate NOT LIKE '0001-01-01'
ORDER BY memberName", __FILE__, __LINE__);
if(db_affected_rows() != 0)
{
$birthdays = array();
$member = array();
while ($row = mysql_fetch_assoc($query))
{
$day = substr($row['birthdate'],8,2);
$birthdays[$row['memberName']] = $day;
$member[$row['memberName']] = $row['ID_MEMBER'];
}
asort($birthdays);
foreach ($birthdays as $key => $value)
{
echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $member[$key] . '">' . $key . '</a> (' . $value . '.' . $month . ')<br />';
}
}
else
echo 'No birthdays this month';
echo' </div>
</div> ';
I did another version of this:
- The dates are in a table (see attached screenshot). I think it looks neater.
- Uses the title and formatting from the block. It wasn't lining up nicely with the other blocks on the side.
- Only shows birthdays for those who have logged into the forum within the past year.
Anyway, here's the code. I don't get any errors from it. YMMV. :)
global $db_prefix, $scripturl;
$last_year = date('U') - (365 * 24 * 60 * 60);
$month = date('m');
$month_number = '-' . $month . '-';
$query = db_query(
"SELECT ID_MEMBER, memberName, birthdate
FROM {$db_prefix}members
WHERE birthdate LIKE '%$month_number%'
AND birthdate NOT LIKE '0001-01-01'
AND lastLogin > '$last_year'
ORDER BY memberName", __FILE__, __LINE__);
if(db_affected_rows() != 0)
{
$birthdays = array();
$member = array();
while ($row = mysql_fetch_assoc($query))
{
$day = substr($row['birthdate'],8,2);
$birthdays[$row['memberName']] = $day;
$member[$row['memberName']] = $row['ID_MEMBER'];
}
asort($birthdays);
echo '<table>';
$yesterday = 0;
foreach ($birthdays as $key => $value)
{
if ($value <> $yesterday)
{
if ($yesterday > 0)
echo '</td></tr>';
echo '<tr valign="top"><td>' , $value , '</td><td>';
}
echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $member[$key] . '">' . $key . '</a><br />';
$yesterday = $value;
}
echo '</td></tr></table>';
}
else
echo 'No birthdays this month';
That's cool! :up:
Very nice... ;D
Awesome, is there a way to limit this to a particular member group or multiple member groups?
Can we add an image to this, like on top of the list?
Rocket, yeah, I'm sure it can be done. Seems like a lot of work for just a list of birthdays. Don't all your members have birthdays? ;)
RebelRose, it would be easy enough to put an image before the list starts. Just put your image tag before echo '<table>';
What code would I use exactly, sorry JPDeni, not great with code but I am trying.
Sorry. :)
Hmmmm. I guess it depends on where your image is. If you always want to use the same image, no matter what theme the user has active, just use
echo '<img src="http://yourdomain.com/url/to/image.gif">';
If the image is in the theme image directories
echo '<img src="', $settings['images_url'], '/image.gif" alt="Happy birthday!" />';
With this second one, you'll also want to change the first line of the code to
global $db_prefix, $scripturl, $settings;
Quote from: JPDeni on October 21, 2006, 07:50:47 PM
Sorry. :)
Hmmmm. I guess it depends on where your image is. If you always want to use the same image, no matter what theme the user has active, just use
echo '<img src="http://yourdomain.com/url/to/image.gif">';
If the image is in the theme image directories
echo '<img src="', $settings['images_url'], '/image.gif" alt="Happy birthday!" />';
With this second one, you'll also want to change the first line of the code to
global $db_prefix, $scripturl, $settings;
Thank you very much.
Cool man...thanks! :)
I know my question might be very stupid, but I have to ask (the code is great and works very nice, Thank you for sharing) Is it possible to center the date and names on page?
I am all new to php coding and it is really something I struggle to understand and I guess I never will be able to :-\
However if possible what do I do :-)
I did mange to put in the code for image and I was able to center that but I can't find out if it's possible to center the names and date as well :-)
Thank you for reading
Do you want to center the table on the page or do you want to center each individual name and date? And, just to be sure, are you referring to the code that lists all the birthdays in the month or the one that says "Happy birthday" on the member's birthday. There's two different types of code in this topic. :)
Oh my.
I think I want to center the names?
Look here http://www.ccsnakk.com/treffstedet/
I have put the code in an article , yes?
And also an image and text saying happy Birthday (in Norwegian, ;D)
And then I wanted to center the names under there. I think.........not sure what's the best,since the image and "my text" are centered
Not sure sorry, but I guess you might understand when you see?
Hopefully.
Thank you for reply
Well, actually, it was more designed for a side block. You can see it on my site (http://site.jpdeni.com/). You're going to end up with a list that's a lot narrower than your image. You might be better off having them all in one line, rather than the table or each person's name on a separate line.
Instead of
asort($birthdays);
echo '<table>';
$yesterday = 0;
foreach ($birthdays as $key => $value)
{
if ($value <> $yesterday)
{
if ($yesterday > 0)
echo '</td></tr>';
echo '<tr valign="top"><td>' , $value , '</td><td>';
}
echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $member[$key] . '">' . $key . '</a><br />';
$yesterday = $value;
}
echo '</td></tr></table>';
You could use
asort($birthdays);
echo '<div style="text-align:center;">';
foreach ($birthdays as $key => $value)
{
echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $member[$key] . '">' . $key . '</a> (',$value,')';
}
echo '</div>';
I think that would probably look a little better, with your wide graphic.
Thank you :-)
I'll try that.
I was not aware that it was meant to be in a sideblock. But if this change don't work for me then I know now and will tru that out.........
Again - Thank you
wow, lost track of this post.. :o
JP, yes, all members do have birthdays.. :) but we run a clan site and I was thinking of just showing birthdays for squad members.
Some people who join the site, are not necessarily friendly to the group and we don't necessarily want to celebrate their birthday! :P
I see. :)
You can alter the query, but I'm not sure how you need it altered.
Here's the original query:
"SELECT ID_MEMBER, memberName, birthdate
FROM {$db_prefix}members
WHERE birthdate LIKE '%$month_number%'
AND birthdate NOT LIKE '0001-01-01'
ORDER BY memberName", __FILE__, __LINE__);
If you wanted only one primary group to be included, after the "WHERE" line you would add something like
AND ID_GROUP = 3
which would mean that only those who have primary group 3 would have their birthdays listed.
If you have two groups that you want to include, you would add
AND (ID_GROUP = 3 OR ID_GROUP= 2)
If you wanted to exclude a particular primary group, you could add something like
AND ID_GROUP <> 3
because we don't like the people in group 3 and we don't care when their birthday is. :)
It gets a little more complicated when you are looking at secondary groups, because there can be multiples. Let's just start with one possibility and if that doesn't work for you, we can go on. Let's say that the bad people are in the 32 secondary group. You would add the following after the WHERE line:
AND NOT FIND_IN_SET('32',additionalGroups)
If you only wanted to show for one secondary group (and that group was number 23), you would use
AND FIND_IN_SET('23',additionalGroups)
I think. :) I haven't tested any of this, but this is what seems would work.
Sounds good JP, I will test it out and let you know what happens!
That darn group 32.. you just can't trust'em! ^-^
Thanks for the help!
For your future reference Rocket, JPDeni = Sis not Bro.... :2funny:
LMAO... ok, I'll make the edit now! :o :D :buck2:
Sorry JP, I guess I need to pay more attention around here! :uglystupid2:
Thank You.
Hi,
I have this for my bday block
Quoteglobal $db_prefix, $scripturl;
$last_year = date('U') - (365 * 24 * 60 * 60);$month = date('m');$month_number = '-' . $month . '-';$query = db_query( "SELECT ID_MEMBER, memberName, birthdate FROM {$db_prefix}members WHERE birthdate LIKE '%$month_number%' AND lastLogin > '$last_year' ORDER BY memberName", __FILE__, __LINE__);
if(db_affected_rows() != 0){ $birthdays = array(); $member = array(); while ($row = mysql_fetch_assoc($query)) { $day = substr($row['birthdate'],8,2); $birthdays[$row['memberName']] = $day; $member[$row['memberName']] = $row['ID_MEMBER']; } asort($birthdays); echo '<table>'; $yesterday = 0; foreach ($birthdays as $key => $value) { if ($value <> $yesterday) { if ($yesterday > 0) echo '</td></tr>'; echo '<tr valign="top"><td>' , $value , '</td><td>'; } echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $member[$key] . '">' . $key . '</a>
'; $yesterday = $value; } echo '</td></tr></table>';}else echo 'Não há aniversários este mês';
But today, 01-01-2007, everyone that doesn't have their birthday entered on their profile show up as it's their birthday today ! LOL
Any help on this?
Cheers,
J!
here dont say I never gave yall something ;D
<?php
global $context, $memberContext, $settings, $options, $scripturl, $txt, $modSettings, $user_info, $user_profile, $sourcedir, $db_prefix;
##############################################################Storms holiday Block######################################################
////////////////////user time settings get
$member_name = $context['user']['name'];
$request = db_query("
SELECT *
FROM {$db_prefix}members
WHERE realName = '$member_name' ", __FILE__, __LINE__);
if(mysql_num_rows($request)>0){
while ($row = mysql_fetch_assoc($request))
{
$bday = $row['birthdate'];
$qoffset = $row['timeOffset'];
$user_time_format = $row['timeFormat'];
$memID = $row['Full Texts ID_MEMBER'];
}
mysql_free_result($request);
}
$user_time = $context['current_time'];
$user_time_chk = strftime ("$user_time_format",time()+$qoffset*3600);
////////// BIRTHDAY OVERIDE
// Split up the birthdate....
list ($uyear, $umonth, $uday) = explode('-', $bday);
$context['member']['birth_date'] = array(
'year' => $uyear,
'month' => $umonth,
'day' => $uday
);
// Set the age...
if (empty($bday))
{
$context['member'] += array(
'age' => &$txt[470],
'today_is_birthday' => false
);
}
else
{
list ($birth_year, $birth_month, $birth_day) = sscanf($bday, '%d-%d-%d');
$datearray = getdate(forum_time());
$context['member'] += array(
'age' => $birth_year <= 4 ? $txt[470] : $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 0 : 1),
'today_is_birthday' => $datearray['mon'] == $birth_month && $datearray['mday'] == $birth_day
);
}
if($context['member']['today_is_birthday']){
$birth = true;
}
?>
This works correctly I'm currently using it to on a theme Im doing for year round holidays, birthdays, and Daily Default once the themes ready you'll see this code in action
8)
So... I just cram that into a php box? :D
LMAO well you could but it wouldnt show you anything. That doesnt include the echo's to show a birthday plus its setup to check each user as they login on an individual base if you want it too show everyones birthday than you'll have to do some changes but in the case the ssi function would be best, unless you wanting specific member groups and if thats the case look at jp's previous reply as she explains it better than i do and is probably more what your personally looking for.
I guess so.
The thing is that what I posted seem to work perfectly allright... but then it was 1-1-2007 and everyone who didn't set the b-day date shows up on the first day of january :S
part of it is that its not checking for validity. Default bday is jan 1 .
this statement in mine is what checks it
// Set the age...
if (empty($bday))
{
$context['member'] += array(
'age' => &$txt[470],
'today_is_birthday' => false
);
}
else
{
list ($birth_year, $birth_month, $birth_day) = sscanf($bday, '%d-%d-%d');
$datearray = getdate(forum_time());
$context['member'] += array(
'age' => $birth_year <= 4 ? $txt[470] : $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 0 : 1),
'today_is_birthday' => $datearray['mon'] == $birth_month && $datearray['mday'] == $birth_day
);
}
but you'd have to change it to suite you and your code.
You can kill the jan 1 bdays all together or you can kill jan 1 birthdays where age is 1 lol and that would also work with an if else check
Well, I know nothing of programming so I can't do it :(
Have to wait for JP or could you try and fix it?
It would be your first good dead of the year :P
bad news bro the way your code is laid out its doing a monthly comparision.
Birthdays are in this format in the database 01-01-0001 m d y what your code is doing is pulling out anybodys birthday with todays month period, thats logged in within the last year. to kill the year of the default it really needs to be totally rewritten. I'll take a look see at what i can come up with for you.
Many many thanks, StormLrd !
]global $db_prefix, $scripturl;
$last_year = date('U') - (365 * 24 * 60 * 60);$month = date('m');$month_number = '-' . $month . '-';$query = db_query( "SELECT ID_MEMBER, memberName, birthdate FROM {$db_prefix}members WHERE birthdate LIKE '%$month_number%' AND lastLogin > '$last_year' AND birthdate <> '0001-01-01' ORDER BY memberName", __FILE__, __LINE__);
if(db_affected_rows() != 0){ $birthdays = array(); $member = array(); while ($row = mysql_fetch_assoc($query)) { $day = substr($row['birthdate'],8,2); $birthdays[$row['memberName']] = $day; $member[$row['memberName']] = $row['ID_MEMBER']; } asort($birthdays); echo '<table>'; $yesterday = 0; foreach ($birthdays as $key => $value) { if ($value <> $yesterday) { if ($yesterday > 0) echo '</td></tr>'; echo '<tr valign="top"><td>' , $value , '</td><td>'; } echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $member[$key] . '">' . $key . '</a><br />'; $yesterday = $value; } echo '</td></tr></table>';}else echo 'Não há aniversários este mês';
its ugly but that should work it just kills any birthday that is jan 1 0001
I realized only today what the problem is. Sorry.
When they upgraded to SMF 1.1, they changed the structure of the birthdays. It used to be 0004-00-00, but they changed it to 0001-01-01. And without telling me first. The nerve! :)
Anyway, I've gone through all of the instances of my code in this topic and added the necessary line to make it work right.
I like this block, thanks for sharing. Currently it looks like this:
08 Scott
if Scott's birthday is the 8th of the month. How hard would it be to get it to look like this?
8th Scott (42)
Showing the persons age in parens.
Sorry for taking so long to answer your question, scott. I got your answer, though.
global $db_prefix, $scripturl;
$last_year = date('U') - (365 * 24 * 60 * 60);
$month = date('m');
$month_number = '-' . $month . '-';
$query = db_query(
"SELECT ID_MEMBER, memberName, birthdate
FROM {$db_prefix}members
WHERE birthdate LIKE '%$month_number%'
AND birthdate NOT LIKE '0001-01-01'
AND lastLogin > '$last_year'
ORDER BY memberName", __FILE__, __LINE__);
if(db_affected_rows() != 0)
{
$birthdays = array();
$member = array();
while ($row = mysql_fetch_assoc($query))
{
$day = substr($row['birthdate'],8,2);
$birthdays[$row['memberName']] = $day;
$member[$row['memberName']] = $row['ID_MEMBER'];
$year = substr($row['birthdate'],0,4);
if ($year <> '0001' && $year <> '0004')
{
$age[$row['memberName']] = date('Y') - $year;
$age[$row['memberName']] = '(' . $age[$row['memberName']] . ')';
}
else
$age[$row['memberName']] = '';
}
asort($birthdays);
echo '<table>';
$yesterday = 0;
foreach ($birthdays as $key => $value)
{
if ($value <> $yesterday)
{
if ($yesterday > 0)
echo '</td></tr>';
echo '<tr valign="top"><td>' , $value , '</td><td>';
}
echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $member[$key] . '">' . $key . '</a> ' . $age[$key] . '<br />';
$yesterday = $value;
}
echo '</td></tr></table>';
}
else
echo 'No birthdays this month';
I didn't do the "8th" thing, though. Having "8th" instead of "08" is really easy, but it starts to get a bit more complicated when you have to think about "st" and "nd" and "rd." I haven't delved enough into the date functions to know how much I can get php to do for me on that. I don't suppose it would be too hard to just eliminate the opening 0s, if you'd like to do that.
Thanks, it looks great. ;D
Instead of "MONTH" Birthdays as the title
I made it say Birthdays in "MONTH"
(you can make it say whatever you want)
You are going to have to modify the line in your bday block which is:
$title = date('F') . ' Birthdays';
change to
$title = 'Birthdays in ' . date('F');
If you follow the steps right and see where i am going with this you will know how to make it say anything you want. Like it could say
"MONTH" Gangsters lol. :2funny: i wouldnt make it that but thats an example :) ;)
I want my bday block (IF POSSIBLE ;))
I want to keep the layout:
global $db_prefix, $scripturl;
$title = 'Birthdays in ' . date('F');
echo '
<div class="tborder" style="margin-bottom: 5px;">
<div class="catbg2" style="padding: 4px; font-weight: bold;">';
echo $title;
echo '
</div>
<div class="windowbg" style="padding: 4px; ">';
$month = date('m');
$month_number = '-' . $month . '-';
$query = db_query(
"SELECT ID_MEMBER, memberName, birthdate
FROM {$db_prefix}members
WHERE birthdate LIKE '%$month_number%'
AND birthdate NOT LIKE '0001-01-01'
ORDER BY memberName", __FILE__, __LINE__);
if(db_affected_rows() != 0)
{
$birthdays = array();
$member = array();
while ($row = mysql_fetch_assoc($query))
{
$day = substr($row['birthdate'],8,2);
$birthdays[$row['memberName']] = $day;
$member[$row['memberName']] = $row['ID_MEMBER'];
}
asort($birthdays);
foreach ($birthdays as $key => $value)
{
echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $member[$key] . '">' . $key . '</a> (' . $value . '.' . $month . ')<br />';
}
}
else
echo 'No birthdays this month';
echo' </div>
</div> ';
Except I would like the birthdays to be displayed like:
Brianjw (AGE HERE)
Bob (AGE HERE)
etc. etc.
The display you want is, basically, the last code I gave, except that it also gives the date of the month that the birthday is. It's a little silly, I think, to say "Bob has a birthday some day this month and is going to be 23 years old."
@JPDeni: Nice block you've created. But is it possible to show not all birthdays for the month, but just the ones for (let's say) the next 10 days ? That would be great :coolsmiley:
Not without completely rewriting the code.
I was in the process of testing this, but my server went down. You can give it a try. I'll try working on it some more if I ever get my site back.
global $db_prefix, $scripturl;
$number_of_days = 10;
$last_year = date('U') - (365 * 24 * 60 * 60);
$low_date = strftime('%Y-%m-%d', forum_time(false) - 24 * 3600);
$high_date = strftime('%Y-%m-%d', forum_time(false) + $number_of_days * 24 * 3600);
if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
$allyear_part = "birthdate BETWEEN '0004" . substr($low_date, 4) . "' AND '0004-12-31'
OR birthdate BETWEEN '0004-01-01' AND '0004" . substr($high_date, 4) . "'";
else
$allyear_part = "birthdate BETWEEN '0004" . substr($low_date, 4) . "' AND '0004" . substr($high_date, 4) . "'";
$year_low = (int) substr($low_date, 0, 4);
$year_high = (int) substr($high_date, 0, 4);
$query= db_query("
SELECT ID_MEMBER, realName, YEAR(birthdate) AS birthYear, birthdate
FROM {$db_prefix}members
WHERE YEAR(birthdate) != '0001'
AND ($allyear_part
OR DATE_FORMAT(birthdate, '{$year_low}-%m-%d') BETWEEN '$low_date' AND '$high_date'" . ($year_low == $year_high ? '' : "
OR DATE_FORMAT(birthdate, '{$year_high}-%m-%d') BETWEEN '$low_date' AND '$high_date'") . ")
AND lastLogin > '$last_year'
ORDER BY memberName", __FILE__, __LINE__);
if(db_affected_rows() != 0)
{
$birthdays = array();
$member = array();
while ($row = mysql_fetch_assoc($query))
{
$day = substr($row['birthdate'],8,2);
$month = substr($row['birthdate'],5,2);
$birthdays[$row['realName']] = $month . $day;
$member[$row['realName']] = $row['ID_MEMBER'];
}
echo '<table>';
asort($birthdays);
$yesterday = 0;
foreach ($birthdays as $key => $value)
{
if ($value <> $yesterday)
{
if (substr($value,0,2) == date("m"))
$showdate = date("M") . ' ' . substr($value,2,2);
else
$showdate = date("M",time() + ($number_of_days * 24 * 3600)) . ' ' . substr($value,2,2);
if ($yesterday > 0)
echo '</td></tr>';
echo '<tr valign="top"><td>' , $showdate , '</td><td>';
}
echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $member[$key] . '">' . htmlspecialchars_decode($key) . '</a><br />';
$yesterday = $value;
}
echo '</td></tr></table>';
}
else
echo 'No birthdays in the next ' . $number_of_days . 'days';
tnx for helping, but i've get a error
Parse error: syntax error, unexpected ';' in /[...]/Sources/Load.php(1748) : eval()'d code(35) : eval()'d code on line 50
I don't see what's wrong with the ';'
Again, tnx in advange
I was missing an end parenthesis. I'll go fix it.
Last night I found another code
global $scripturl, $modSettings, $context, $db_prefix, $user_profile;
smf_loadCalendarInfo();
$now = mktime() + $modSettings['time_offset'] * 3600;
$today = date('j',$now);
$year = date('Y',$now);
$month = date('n',$now);
$days = array($today=>array(NULL,NULL,'<a class="smalltext" style="color:steelblue; font-weight:bold; border:solid 1px black; background-color: white; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$today.'" target="_self">'.$today.'</a>'));
$day_name_length = 2;
$month_href = $scripturl . '?action=calendar&month=' . $month;
$first_day = 0;
$pn = array();
$first_of_month = gmmktime(0,0,0,$month,1,$year);
$day_names = array(); #generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name
list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
$title = htmlentities(ucfirst($month_name)).' '.$year; #note that some locales don't capitalize month and day names
@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
if($p) $p = '<span class="smalltext">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="smalltext">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table align="center">'.'<caption >'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n.'</caption><tr>';
if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
foreach($day_names as $d)
$calendar .= '<th class="smalltext" abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= '</tr><tr style="text-align:right;">';
}
if($weekday > 0) $calendar .= '<td class="smalltext" colspan="'.$weekday.'"> </td>'; #initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday = 0; #start a new week
$calendar .= '</tr><tr style="text-align:right;">';
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content)) $content = $day;
$calendar .= '<td '.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else
{
$calendar .= '<td class="smalltext" style="padding-right:4px;"><a';
if(((($weekday+$first_day) % 7)==0)||((($weekday+$first_day) % 7)==6))
{
$calendar .= ' style="color:#C00000;"';
}
$calendar .= ' href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$day.'" target="_self">'.$day.'</a></td>';
}
}
if($weekday != 7) $calendar .= '<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days
echo $calendar.'</tr>';
/////////////////////////////////////////////////////////////////
// BIRTHDAY SECTION
//
if (!empty($context['calendar_birthdays']))
{
echo '<tr><td colspan="2"><hr></td><td colspan="3" class="smalltext" align="center" style="font-weight: bold; color: #' . $modSettings['cal_bdaycolor'] . ';">Birthdays</td><td colspan="2"><hr></td></tr><td colspan="7" class="smalltext">';
foreach ($context['calendar_birthdays'] as $member)
{
$query = db_query(
"SELECT birthdate
FROM {$db_prefix}members
WHERE ID_MEMBER='".$member['id']."'", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);
list ($uyear, $umonth, $uday) = explode('-', $row['birthdate']);
$birthdate = strtotime(sprintf('%04d-%02d-%02d', date("Y"), $umonth, $uday));
mysql_free_result($query);
$dummy = array();
$dummy[] = $member['id'];
loadMemberData($dummy);
$profile = &$user_profile[$member['id']];
echo '<div align="center">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$birthdate) . '"><strong>' . date("M j",$birthdate) . '</strong></a>';
echo ' - ';
echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '">';
if (!empty($profile['member_group_color']))
{
echo '<font color="' . $profile['member_group_color'] . '">' . $member['name'] . (isset($member['age']) ? '(' . $member['age'] . ')' : '') . '</font>';
}
else
{
echo $member['name'] . (isset($member['age']) ? '(' . $member['age'] . ')' : '');
}
echo '</a>';
echo '</div>';
}
echo '</td></tr>';
}
/////////////////////////////////////////////////////////////////
// EVENTS SECTION
//
if (!empty($context['calendar_events']))
{
echo '<tr><td colspan="2"><hr></td><td colspan="3" class="smalltext" align="center" style="font-weight: bold; color: #' . $modSettings['cal_eventcolor'] . ';">Events</td><td colspan="2"><hr></td></tr><td colspan="7" class="smalltext">';
foreach ($context['calendar_events'] as $event)
{
$query = db_query(
"SELECT startDate
FROM {$db_prefix}calendar
WHERE ID_EVENT='".$event['id']."'", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);
$startdate = strtotime($row['startDate']);
mysql_free_result($query);
echo '<div align="center">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$startdate) . '"><strong>' . date("M j",$startdate) . '</strong></a>';
echo ' - ';
echo $event['link'] ;
echo '</div>';
}
echo '</td></tr>';
}
/////////////////////////////////////////////////////////////////
// HOLIDAY SECTION
// WHERE title='".str_replace("'","''",$holiday)."'
if (!empty($context['calendar_holidays']))
{
echo '<tr><td colspan="2"><hr></td><td colspan="3" class="smalltext" align="center" style="font-weight: bold; color: #' . $modSettings['cal_holidaycolor'] . ';">Holidays</td><td colspan="2"><hr></td></tr><td colspan="7" class="smalltext">';
foreach ($context['calendar_holidays'] as $holiday)
{
$query = db_query(
"SELECT eventDate
FROM {$db_prefix}calendar_holidays
WHERE title='".str_replace("'","''",$holiday)."'
AND (eventDate LIKE '".date("Y")."-%' OR eventDate LIKE '0004-%')", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);
$eventdate = strtotime(date("Y").substr($row['eventDate'], 4));
mysql_free_result($query);
echo '<div align="center">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$eventdate) . '"><strong>' . date("M j",$eventdate) . '</strong></a>';
echo ' - ';
echo $holiday;
echo '</div>';
}
echo '</td></tr>';
}
echo '</table>';
which I've turned over into
global $scripturl, $modSettings, $context, $db_prefix, $user_profile;
smf_loadCalendarInfo();
$now = mktime() + $modSettings['time_offset'] * 3600;
$today = date('j',$now);
$year = date('Y',$now);
$month = date('n',$now);
$days = array($today=>array(NULL,NULL,'<a class="smalltext" style="color:steelblue; font-weight:bold; border:solid 1px black; background-color: white; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$today.'" target="_self">'.$today.'</a>'));
$day_name_length = 2;
$month_href = $scripturl . '?action=calendar&month=' . $month;
$first_day = 0;
$pn = array();
$first_of_month = gmmktime(0,0,0,$month,1,$year);
$day_names = array(); #generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name
list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
$title = htmlentities(ucfirst($month_name)).' '.$year; #note that some locales don't capitalize month and day names
@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
$calendar = '<table><tr>';
echo $calendar.'</tr>';
/////////////////////////////////////////////////////////////////
// BIRTHDAY SECTION
//
if (!empty($context['calendar_birthdays']))
{
echo '<tr><td colspan="3" class="smalltext" align="center" style="font-weight: bold; color: #' . $modSettings['cal_bdaycolor'] . ';">Upcoming Birthdays</td></tr><td colspan="7" class="smalltext">';
foreach ($context['calendar_birthdays'] as $member)
{
$query = db_query(
"SELECT birthdate
FROM {$db_prefix}members
WHERE ID_MEMBER='".$member['id']."'", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);
list ($uyear, $umonth, $uday) = explode('-', $row['birthdate']);
$birthdate = strtotime(sprintf('%04d-%02d-%02d', date("Y"), $umonth, $uday));
mysql_free_result($query);
$dummy = array();
$dummy[] = $member['id'];
loadMemberData($dummy);
$profile = &$user_profile[$member['id']];
echo '<div>';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$birthdate) . '"><strong>' . date("M j",$birthdate) . '</strong></a>';
echo ' - ';
echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '">';
if (!empty($profile['member_group_color']))
{
echo '<font color="' . $profile['member_group_color'] . '">' . $member['name'] . (isset($member['age']) ? '(' . $member['age'] . ')' : '') . '</font>';
}
else
{
echo $member['name'] . (isset($member['age']) ? '(' . $member['age'] . ')' : '');
}
echo '</a>';
echo '</div>';
}
echo '</td></tr>';
}
/////////////////////////////////////////////////////////////////
// EVENTS SECTION
//
if (!empty($context['calendar_events']))
{
echo '<tr><td colspan="3" class="smalltext" align="center" style="font-weight: bold; color: #' . $modSettings['cal_eventcolor'] . ';">Upcoming Events</td></tr><td colspan="7" class="smalltext">';
foreach ($context['calendar_events'] as $event)
{
$query = db_query(
"SELECT startDate
FROM {$db_prefix}calendar
WHERE ID_EVENT='".$event['id']."'", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);
$startdate = strtotime($row['startDate']);
mysql_free_result($query);
echo '<div>';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$startdate) . '"><strong>' . date("M j",$startdate) . '</strong></a>';
echo ' - ';
echo $event['link'] ;
echo '</div>';
}
echo '</td></tr>';
}
/////////////////////////////////////////////////////////////////
// HOLIDAY SECTION
// WHERE title='".str_replace("'","''",$holiday)."'
if (!empty($context['calendar_holidays']))
{
echo '<tr><td colspan="3" class="smalltext" style="font-weight: bold; color: #' . $modSettings['cal_holidaycolor'] . ';">Upcoming Holidays</td></tr><td colspan="7" class="smalltext">';
foreach ($context['calendar_holidays'] as $holiday)
{
$query = db_query(
"SELECT eventDate
FROM {$db_prefix}calendar_holidays
WHERE title='".str_replace("'","''",$holiday)."'
AND (eventDate LIKE '".date("Y")."-%' OR eventDate LIKE '0004-%')", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);
$eventdate = strtotime(date("Y").substr($row['eventDate'], 4));
mysql_free_result($query);
echo '<div>';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$eventdate) . '"><strong>' . date("M j",$eventdate) . '</strong></a>';
echo ' - ';
echo $holiday;
echo '</div>';
}
echo '</td></tr>';
}
echo '</table>';
This does exactly what I want. I've put it under the infobox without frame and title.
But still many thanks to JPDeni :up:
Cool. I'm glad you found what you wanted. Next time, try to describe everything that you want. You had said that you liked the block that I had written, but just wanted to have it display the birthdays in the next 10 days. That's what I gave you. If I had known you wanted something else, I would have written something else or maybe just found what you did.
I don't mind writing code for people, but it bothers me a lot to waste my time.
I can imagine that it bothers you. Seems very, very fair to me.
In this case... the reason is, I ran into your code what looked like a good base for my idea. But I've should heaved use the search or something. Anyway, you were damn fast with a answer and new code 8)
However I figured already that it would bother you. (as it would bother me too). So ... I had 2 options ... or run away from this topic, or give back some code together with many thanks.
And, once more, tnx and I hope you will forgive me (read: I hope you will help me in the future :-X )
PS. I'm not writing in English every day. I hope you understand what i wanted to tell.
I understand. :) And I will help you in the future. Just try to descrbe exactly what you want when you ask for something. That's the worst part of helping people. Don't feel bad, though. It happens all the time.
[off topic]
QuoteThe Amiga is by far my favorite, but I finally had to bow to the inevitable and get a PC. I do still work on the Amiga from time to time, though.
Carol, you are the best! That 500 still rulez. I've waited till win98SE before I 'bow' :up:
[/off topic]
I am using the code from JPDeni , works fine, but today i noticed someone's birthday didn't go away, his birthday was yesterday but today i still see his name in the block. Guess that aint right
I just removed the block cause 2 days later the same guy is still having his birthday :uglystupid2:
all the code works fine but is it easy to get the date format the same as the Forum standard (in my case the Dutch one 5 september 2007 or 5 sep will just do the job.
one new question is:
is it easy to make a birthday calander whit the member avatar included.
okay, how about a version of that last snippet that shows upcoming birthdays and holidays, but for an entire month and NOT showing my members' ages? Just birthdays this month, showing the day, for the current month. Some people are sensitive about their ages being public in my forum.
Thanks.
hey there,
i know this topic is kinda old, but i'm searching for a special birthday snippet for a block. i tried hard to combine several snippets to fit my needs, but didn't get it working.
what i am looking for is a snippet to primary display the upcoming birthdays of the present month followed by the birthdays already passed in this month. also the snippet should display when the user's birthday is and how old he gets. so e.g. like this
"
Upcoming birthdays for August:
User 1 (20) on 8/14
User 2 (34) on 8/25
Passed birthdays:
User 6 (18) on 8/3
User 19 (23) on 8/10
"
or, don't know if that's easier to code, just display the upcoming birthdays for the next 30 days, followed by the last 10 days' birthdays. the layout just the same as mentioned above ;)
maybe i've slipped over the appropriate snippet, so be kind to just post it underneath, or, be so kind as to code it for me ::)
its not the slightest hurry ;)
thanks
addition:
i currently don't know a lot about smf and tp, i'm new to it, but maybe, if it's not too complicated, one might display today's birthday(s) at the top like:
"
Today's birthday(s) (8/13):
User 34 (13)
Upcoming Birthdays for August.... (continue as stated above)
"
what i now also see, i haven't mentioned to like to have a link to the users displayed in the block, so one can get to their profil.
thanks a lot again
are you looking for something similiar to this: http://www.blindskill.info/forum/index.php
view the heavens day block
I'll post the code up shortly
This actually uses hard links and the children that have died on windowblinds so I'll have to modify it to pull from the member list if your interested.
even though i thought at first sight, this isn't what i am looking for, after a while, it just looks like the type of thing, i was looking for.
so, if you get the code modified to fit my needs, i would be very grateful.
If you are looking for something that isn't found, please post in the request board to see if anyone would like to help you.
My birthday is November 7, 1937 :tickedoff: My son Scott's is March 3, 1966 :laugh: