PDA

View Full Version : Birthdays in Current Month


KatieG
10-07-2012, 05:37 AM
I am trying to display the user birthdays this month

I have done the script below, although there is a birthday set this month
it shows " No Birthdays This Month "

Can anyone help please

<?php


include("connect.php");


$result = mysql_query("SELECT userid,username,birthday FROM user WHERE MONTH(birthday) = MONTH(NOW())");
if( mysql_num_rows( $result ) != 0 ) {
while ( $row = mysql_fetch_array($result))
{
$userid = $user['userid'];
$username = $user['username'];
$birthday = $user['birthday'];
$birthday = explode("-", $birthday);
$birthmonth = $birthday[0];
if ($birthmonth = $month)
{
echo "<a href='member.php?u=$userid'>$username</a>,&nbsp;";
}

}
}
else{
echo "No Birthdays This Month";
}
?>

kh99
10-07-2012, 10:39 AM
Change your query to use
...WHERE MONTH(birthday_search) = MONTH(NOW())


(add the _search). I guess it's because the birthday field isn't one of the date formats that MySql will use or something like that. Anyway, I the rest of your code can still use the birthday column if you want.

Tyran1
01-19-2013, 10:57 AM
works??

BGObsession
02-16-2014, 05:23 PM
I have tried this code and it's not working - thoughts anyone?

ozzy47
02-16-2014, 09:49 PM
If the user has, Hide Age and Date of Birth or Display Only Age set, they should not show up.