FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » Birthday hack
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
Birthday hack [message #4352] Wed, 24 July 2002 15:09 Go to next message
heidiott is currently offline  heidiott   United States
Messages: 34
Registered: May 2002
Karma: 0
Member
add to buddy list
ignore all messages by this user
I think it would be fun to have a birthday hack that would pull todays birthdays from the database so that they could be used as an include somewhere on the site... It could say something like...

Todays Birthdays: Username (age), Username (age), etc...

Thank you,
Heidi
Re: Birthday hack [message #4356 is a reply to message #4352] Wed, 24 July 2002 16:31 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
You're more then welcome to write one Wink

FUDforum Core Developer
Re: Birthday hack [message #4386 is a reply to message #4352] Wed, 24 July 2002 22:24 Go to previous messageGo to next message
heidiott is currently offline  heidiott   United States
Messages: 34
Registered: May 2002
Karma: 0
Member
add to buddy list
ignore all messages by this user
I guess I could give it a shot... I know only a little php but it's probably pretty simple Rolling Eyes I'll see what I can do.
Thanks,
Heidi
Re: Birthday hack [message #4408 is a reply to message #4352] Thu, 25 July 2002 21:01 Go to previous messageGo to next message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
something along these lines would get you going in the right direction:


<?php

$db = mysql_connect(<database server>, <username>, <password>);
mysql_select_db(<forum database>, $db);

$result = mysql_query("SELECT * FROM <formum prefix>_users WHERE bday=" . date("Ymd"), $db);
$row = mysql_fetch_array($result, MYSQL_NUM);

echo $row[3] . " is celebrating his/her birthday today.";

?>



this code will not quite work (only gets one person) but it at least gets you started.

*edit* actually you will have to do a regular expression search for birthdays ending with "md" i believe. so that above code doesnt even return one hit.

[Updated on: Thu, 25 July 2002 22:23]

Report message to a moderator

Re: Birthday hack [message #4410 is a reply to message #4408] Thu, 25 July 2002 23:11 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
Except, you'd need to add an INDEX on the bday field, otherwise that query will be VERY slow, especially on forum with many users.

FUDforum Core Developer
Re: Birthday hack [message #4412 is a reply to message #4352] Thu, 25 July 2002 23:49 Go to previous messageGo to next message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
database stuff is not really my thing. ive just started to mess with php and mysql though and am kinda digging the combination. that code was based on the knowledge i have gained in the past two days.
Re: Birthday hack [message #4688 is a reply to message #4352] Fri, 02 August 2002 18:43 Go to previous messageGo to next message
heidiott is currently offline  heidiott   United States
Messages: 34
Registered: May 2002
Karma: 0
Member
add to buddy list
ignore all messages by this user
I did it Cool
Here is the function...


<?php
function bday()
{
include_once "path/to/GLOBALS.php";

$cid = mysql_connect($DBHOST, $DBHOST_USER, $DBHOST_PASSWORD);
mysql_select_db($DBHOST_DBNAME, $cid);
$time = date(m);
$cur_year = date(Y);
$quary ="SELECT id, login, bday FROM fud_users WHERE bday>0";

$result = mysql_query($quary);
//print "This months birthdays...<br>");
while(list($id, $login, $bday) = mysql_fetch_row($result))

{
$month = substr($bday, -4, 2);
$year = substr ($bday, -0, 4);
$age = $cur_year - $year;

if ($month == $time)
{

print ("<a href=\"http://forum_url/index.php?t=usrinfo&id=$id\">$login</a> <span class=\"small\">(<b>$age</b>)</span><br&g t;\n");
}
}
}

?>

Call the function with...

<?php bday(); ?>

I decided to show all birthdays for the current month instead of each day. The code could easily be changed to show birthdays by day.

Have fun!
Heidi
Re: Birthday hack [message #4689 is a reply to message #4352] Fri, 02 August 2002 18:44 Go to previous messageGo to next message
heidiott is currently offline  heidiott   United States
Messages: 34
Registered: May 2002
Karma: 0
Member
add to buddy list
ignore all messages by this user
Oh and if you want to see how it looks on my site go to http://crafterscommunity.com

Heidi

[Updated on: Fri, 02 August 2002 18:44]

Report message to a moderator

Re: Birthday hack [message #4690 is a reply to message #4688] Fri, 02 August 2002 18:59 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
Neat Smile

FUDforum Core Developer
Re: Birthday hack [message #4699 is a reply to message #4352] Sat, 03 August 2002 02:28 Go to previous messageGo to next message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
i like it. now i just need to sit down monday and figure out how to create a bday.tmpl so that i can stick it under the logged in users list table.

oh and you should be able to get away with changing
<a href=\"http://forum_url/index.php?t=usrinfo&id=$id\">$logi n</a>
to
<a href=\"" . $WWW_ROOT . "index.php?t=usrinfo&id=$id\">$login</a>
Re: Birthday hack [message #12592 is a reply to message #4699] Sun, 17 August 2003 15:13 Go to previous messageGo to next message
Anti Turmoil is currently offline  Anti Turmoil   Sweden
Messages: 16
Registered: March 2002
Location: Sweden Lund
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
Are there anyone else who uses this hack on there forum, I can?t connect to crafterscommunity to see how it looks???

http://www.student.lu.se/~spa99esj/bilder/Signaturer/anti_turmoil.gif
Re: Birthday hack [message #13071 is a reply to message #4688] Sun, 21 September 2003 08:25 Go to previous message
aircool5(at)bellsouth(dot)net is currently offline  aircool5(at)bellsouth(dot)net   United States
Messages: 132
Registered: March 2003
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
Where I have to paste this code?

heidiott wrote on Fri, 02 August 2002 18:43

I did it Cool
Here is the function...


<?php
function bday()
{
include_once "path/to/GLOBALS.php";

$cid = mysql_connect($DBHOST, $DBHOST_USER, $DBHOST_PASSWORD);
mysql_select_db($DBHOST_DBNAME, $cid);
$time = date(m);
$cur_year = date(Y);
$quary ="SELECT id, login, bday FROM fud_users WHERE bday>0";

$result = mysql_query($quary);
//print "This months birthdays...<br>");
while(list($id, $login, $bday) = mysql_fetch_row($result))

{
$month = substr($bday, -4, 2);
$year = substr ($bday, -0, 4);
$age = $cur_year - $year;

if ($month == $time)
{

print ("<a href=\"http://forum_url/index.php?t=usrinfo&id=$id\">$login</a> <span class=\"small\">(<b>$age</b>)</span><br&g t;\n");
}
}
}

?>

Call the function with...

<?php bday(); ?>

I decided to show all birthdays for the current month instead of each day. The code could easily be changed to show birthdays by day.

Have fun!
Heidi

Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: Default font size changes
Next Topic: chinese search
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Oct 17 11:15:28 EDT 2017

Total time taken to generate the page: 0.00767 seconds