homepage Welcome to WebmasterWorld Guest from 54.227.11.45
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
How to display To todays birthdays
please some one help me
phprockz




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

Hi,
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.

 

neo_brown




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

Get the date using php's Date function.
[uk.php.net...]

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.

phprockz




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

i tried this

<?php require_once('Connections/connBlog.php');?>
<?php
$today= date("y-m-d");
echo $today;
?>
<?php
$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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>

<table border="0">
<tr>
<td>username</td>
<td>birthday</td>
</tr>
<?php do {?>
<tr>
<td><?php echo $row_Recordset1['firstName'];?></td>
<td><?php echo $row_Recordset1['birthday'];?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));?>
</table>
</body>
</html>
<?php
mysql_free_result($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.

omoutop




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

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.

phprockz




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

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.

jatar_k




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

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.

coopster




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

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());

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved