<html> <head> <title> </title> <script language="javascript"> <!-- begin hiding // end hiding --> </script> </head> <body> <?php // include custom php functions include( "functions.phtm" ); // global constants $HOST = "localhost"; $DATABASE = "matthew"; $USER = "matthew"; $PASSWORD = "matthewPassword"; // multiple ways to do the same thing // $date1 = (int)date( "z" ) + 1; // $date2 = (int)strftime( "%j" ); // print( "<p><b>$date1</b></p>" ); // echo "<p><b>$date2</b></p>"; $notify = 30; $date = (int)strftime( "%j" ); // get the current date in easy to use array format $dayArray = getdate(); // create a UNIX timestamp for the last day of the recently determined year // int mktime(int hour, int minute, int second, int month, int day, int year); $daysInYear = strftime( "%j", mktime( 0, 0, 0, 12, 31, $dayArray["year"] ) ); // if the current date is within $notify days of $daysInYear // start checking into next year if( $date > ( $daysInYear - $notify ) ) { // how many days to check in to the next year $daysNextYear = $notify - ( $daysInYear - $date ); $condition = "DAYOFYEAR(birthday) >= $date OR DAYOFYEAR(birthday) < $daysNextYear"; } // else check for events within the next $notify days else { $condition = "DAYOFYEAR(birthday) - $date < 30 AND DAYOFYEAR(birthday) - $date >= 0"; } if( mysql_connect( $HOST, $USER, $PASSWORD ) == false ) { fatal( mysql_errno() . ": " . mysql_error() ); } $sql = "select *, MONTH(birthday) AS month, DAYOFMONTH(birthday) AS day, YEAR(birthday) AS year from birthdays where $condition order by month, day, year"; if( ( $result = mysql_db_query( $DATABASE, $sql ) ) == false ) { fatal( mysql_errno() . ": " . mysql_error() ); } if( mysql_num_rows( $result ) == 0 ) { echo "No birthdays within the next $ days..."; } else { echo "<table>\n"; while( $row = mysql_fetch_array( $result ) ) { echo "<tr>"; // another way to access the result rows // echo "<td>" . $row["firstname"] . "</td>"; // echo "<td>" . $row["lastname"] . "</td>"; // echo "<td>" . $row["birthday"] . "</td>"; print( "<td align=right>$row[3]/$row[4]" ); if( $row[5] > 1 ) { print( "/$row[5]" ); } echo "</td>"; print( "<td>$row[0] $row[1]</td>" ); echo "</tr>\n"; } echo "</table>\n"; } mysql_free_result( $result ); ?> </body> </html>