MySQL

Select rows for the current day and month

What does this script do?

This PHP script connects to a MySQL database and retrieves historical events that occurred on today's date (same day and month) from a table called today_in_history.

Demo
YearEvent
1601 Tycho Brahe greatest naked-eye observer dies in Prague.
1775 Continental Congress establishes a navy
1792 Washington lays cornerstone of the Executive Mansion (White House)
1812 Battle of Queenstown Heights.
1843 B'nai B'rith founded in NY.
1845 Texas ratifies a state constitution.
1943 Italy declares war on former ally Germany.
1947 Kukla Fran & Ollie premiers
1953 Burglar alarm - ultrasonic or radio waves - patented - Samuel Bagno
1960 Pirate's Mazeroski's bottom of 9th lead off HR beats Yanks 10-9 in game 7 of World Series
1964 Voshkod 1 crew returns
1969 Soyuz 8 is launched
1971 1st World Series night game (Pitts 4 - Balt 3)
1978 Graig Nettles at 3rd makes spectactular play after spectacular play
1978 Guidry beats Dodgers after trailing 2 games to 0 Yanks win next 4
1982 NJ Devils 1st short handed gaol - Don Lever
1982 Intl Olympic Comm restores 2 gold medals from 1912 Olympics to Jim Thorpe. Medals taken away because he played baseball for pay
1984 Blackhawk Bill Gardner scored on 10th penalty shot against Islanders
1984 John Henry becomes 1st thoroughbred to win $6 million.
1985 13th Space Shuttle Mission - Challenger 6 is launched
1987 1st military use of trained dolphins by US Navy in Persian Gulf.
MySQL Query
SELECT * FROM today_in_history WHERE DAY(mcm_date)=DAY(NOW()) AND MONTH(mcm_date)=MONTH(NOW()) LIMIT 0, 60
PHP
$conn = new mysqli ("server", "user", "password", "database");
mysqli_set_charset ($conn, "utf8");

if ($conn -> connect_error) {
die ("Error: " . $conn->connect_error);
} 

$sql = "SELECT * FROM today_in_history WHERE DAY(mcm_date)=DAY(NOW()) AND MONTH(mcm_date)=MONTH(NOW()) LIMIT 0, 60";
$result = $conn -> query($sql);

echo "<table id='demoTable' class='table table-striped'>";
echo "<thead>";
echo "<tr>";
echo "<th>Year</th>";
echo "<th>Event</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>"; 

while ($row = $result -> fetch_assoc()) { 

$var_year = date_create($row["mcm_date"]);

echo "<tr>";
echo '<td>' . date_format($var_year, 'Y') . '</td>' . "\n";
echo "<td>" . $row["mcm_event"] . "</td>";
echo "</tr>";
}

echo "</tbody>";
echo "</table>";
$conn -> close();
?>