Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

How to display To todays birthdays

please some one help me



3:59 pm on Jan 31, 2006 (gmt 0)

10+ Year Member

I have DOB in my user registeration.I want to know how to display today date birthdays usernames on my homepage please suggest me how to write code for it.Iam new bie to php.


5:38 pm on Jan 31, 2006 (gmt 0)

10+ Year Member

Get the date using php's Date function.

Then format the data to match the format used in your database and store as variable "$todaysdate"
Then simply query the database to display all users where DOB = $todaysdate.
Sorry if you wanted the actual code but its real easy if you already know how to query a database and display the results.


11:55 am on Feb 1, 2006 (gmt 0)

10+ Year Member

i tried this

<?php require_once('Connections/connBlog.php');?>
$today= date("y-m-d");
echo $today;
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_connBlog, $connBlog);
$query_Recordset1 = "SELECT firstName FROM tbl_users WHERE birthday='$today'";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $connBlog) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>


<table border="0">
<?php do {?>
<td><?php echo $row_Recordset1['firstName'];?></td>
<td><?php echo $row_Recordset1['birthday'];?></td>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));?>

and finally i laughed at me because no one will have birthday on today date.My db DOB format is YYYY-MM-DD.I think ishouldnt consider year .I should only consider month and date and we have to match with db's DOB.Please suggest me how can i do like this.


12:19 pm on Feb 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Hi phprockz!

I suggest you to store all dates as unixtime (integer, 11 or 12) while taking a look at the date() function on the php_manual to find out how to convert dates to unixtime as well as compare months and days only.

Hope the best.


1:58 pm on Feb 1, 2006 (gmt 0)

10+ Year Member

MY date format is 2006-02-01.I think its unix format only .Please suggest how to get todays birthdays from database.if u have any logic plz mentiion here.


1:57 am on Feb 2, 2006 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

another option would be to store day, month and year in seperate columns and then select where day equals today and month equals this month.


2:26 pm on Feb 2, 2006 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Or use some date/time functions [dev.mysql.com].

$query_Recordset1 = "SELECT firstName FROM tbl_users WHERE MONTH(birthday) = MONTH(NOW() AND DAY(birthday) = DAY(NOW());

Featured Threads

Hot Threads This Week

Hot Threads This Month