View Full Version : Show today birthdays on a non-vb page
smdani
01-25-2005, 07:04 AM
Hi comunity!
I would like to show TODAY BIRTHDAY's on a non-vb page.
What I dont know how to do is to compare with SQL statment today date DATE(now), with users.birthday_search and find thos users whose celebrate their birthday.
Any help?
Thanks in advance.
Andreas
01-25-2005, 07:20 AM
SELECT username, userid
FROM user
WHERE birthday_search LIKE date_format( now( ) , '%%-%m-%d' )
But you might also want to take a look at table datastore, row title=birthdaycache.
smdani
01-25-2005, 07:39 AM
Thanks a lot KirbyDE,
It works!! Here is the script for anyone that wants to use it!!
<?php
$db_host = "localhost";
$db_name = "***";
$db_user = "***";
$db_pw = "***";
mysql_connect($db_host,$db_user,$db_pw) or die("Imposible conectar con MySql");
mysql_select_db($db_name) or die("No puedo conectar con la BD");
$birthdays = mysql_query("SELECT * FROM user WHERE birthday_search LIKE date_format(now(),'%%%%-%m-%d')");
if ($birthdays == ""){
echo "No hay cumplea?os";
} else {
while ($birthday = mysql_fetch_array($birthdays)) {
$bd_user = $birthday[username];
$bd_userid = $birthday[userid];
$datebits = explode("-", $birthday[birthday_search]);
$bdage = date("Y") - $datebits[0];
if ($bdage > 0) $age = "($bdage)";
else $age = "";
echo "<a href=\"$forum_url/member.php?u=$bd_userid\">$bd_user</a> $age<br>";
}
}
?>
Thanks!!!
"Dad gratis lo que gratis recibisteis" (Jes?s)
Andreas
01-25-2005, 08:04 AM
You are only selecting username and userid, but you also try to process birthday ...
smdani
01-25-2005, 08:06 AM
Corrected and modified above message with correct code!
Thanks
Now I would like to limit birthday show to those users who belongs to a special category created by me on the system.
any idea?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.