Mega Code Archive

 
Categories / Php / MySQL Database
 

List people whose birthdays fall on the current Day and Month

<? // I wanted a simple way to find customers that had birthdays each day // of the week so I could send them a card. Here it is, Hope it helps. ?> <html> <head> <title></title> </head> <body bgcolor="white" link="blue" vlink="magenta" alink="red"> <table width="680" cellpadding="0" cellspacing="0" border="0"> <tr> <td> <? $db = mysql_connect("localhost", "root"); $Date = date("m/d"); mysql_select_db("customers",$db); $result = mysql_query("SELECT * FROM Cinfo WHERE Bday = '$Date'"); echo "<table width='500' align='center' cellpadding='2' cellspacing='2' border=1>\n"; echo "<tr><td>First Name</td><td>Last Name</td><td>Birthday</td><td>Year</td></tr>\n"; while ($myrow = mysql_fetch_row($result)) { printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n", $myrow[1], $myrow[2], $myrow[3], $myrow[4]); } echo "</table>\n"; ?> </td> </tr> <tr> <td> <CENTER> <FONT SIZE="1" COLOR="RED"><B>The date today is,</B></FONT> <FONT SIZE="1" COLOR="NAVY"><? echo date("M. d, Y");?><FONT> </CENTER> </td> </tr> </table> </body> </html>