Birthday hack [message #4352] |
Wed, 24 July 2002 15:09  |
|
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 #4408 is a reply to message #4352] |
Thu, 25 July 2002 21:01   |
 |
JamesS
 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 #4688 is a reply to message #4352] |
Fri, 02 August 2002 18:43   |
|
I did it
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 #13071 is a reply to message #4688] |
Sun, 21 September 2003 08:25  |
|
Where I have to paste this code?
heidiott wrote on Fri, 02 August 2002 18:43 | I did it
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
|
|
|
|