Birthday List

$birthdays_dir = "/home/brianpai/www/www/birthday/";

$curday = date('z', mktime(date(H),0,0, date(m), date(d), date(Y)));

// connect to the database
//
$link = mysql_connect("localhost", "brianpai", "sinep327") or die("Could not connect to the birthdays database.");
mysql_select_db("website") or die("Could not select database");

// get all of the rows in the table
//

$query = "SELECT * FROM tblBirthday ORDER BY DAYOFYEAR(birthday_date) ASC";

$result = mysql_query($query) or die("Couldn't select records");

print("

\n”);
print(”

\n”);

while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$person = $row["birthday_name"];
$datefull = $row["birthday_date"];

list($year, $month, $day) = split(’[/.-]‘, $datefull);
$url = $row["birthday_url"];
$days = date(’z', mktime(0,0,0, $month, $day, $year));

if($days < $curday){
$age = date(Y) - $year;
}
else {
$age = date(Y) - $year - 1;
}

if(strlen($url) > 0)
{
printf(”

\n”, $month, $day, $person, $age);
}
else
{
printf(”

\n”, $month, $day, $person, $age);
}

}
print(”

Birthday Name Age
%s/%s %s %d
%s/%s %s %d

\n”);

// free resultset
//
mysql_free_result($result);

// disconnect from the database
//
mysql_close($link);
?>

Links

Categories

Archives