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

Home » FUDforum Development » Plugins and Code Hacks » Birthday hack
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Birthday hack [message #4352] Wed, 24 July 2002 19:09 Go to next message
heidiott is currently offline  heidiott   United States
Messages: 34
Registered: May 2002
Karma: 0
Member
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 20: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
You're more then welcome to write one Wink

FUDforum Core Developer
Re: Birthday hack [message #4386 is a reply to message #4352] Thu, 25 July 2002 02:24 Go to previous messageGo to next message
heidiott is currently offline  heidiott   United States
Messages: 34
Registered: May 2002
Karma: 0
Member
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] Fri, 26 July 2002 01: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
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: Fri, 26 July 2002 02:23]

Report message to a moderator

Re: Birthday hack [message #4410 is a reply to message #4408] Fri, 26 July 2002 03: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
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] Fri, 26 July 2002 03: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
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 22:43 Go to previous messageGo to next message
heidiott is currently offline  heidiott   United States
Messages: 34
Registered: May 2002
Karma: 0
Member
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 22:44 Go to previous messageGo to next message
heidiott is currently offline  heidiott   United States
Messages: 34
Registered: May 2002
Karma: 0
Member
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 22:44]

Report message to a moderator

Re: Birthday hack [message #4690 is a reply to message #4688] Fri, 02 August 2002 22: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
Neat Smile

FUDforum Core Developer
Re: Birthday hack [message #4699 is a reply to message #4352] Sat, 03 August 2002 06: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
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 19: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
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 12: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
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

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

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

Current Time: Sat Nov 23 03:21:04 GMT 2024

Total time taken to generate the page: 0.02471 seconds