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
1662 Charles II grants a charter to establish Royal Society in London.
1815 Napoleon Bonaparte captured.
1867 SF Merchant's Exchange opens
1870 Georgia readmitted to US after Civil War.
1870 NW Territories created & Manitoba becomes 5th Canadian province.
1918 St. Vladimir's Day
1920 Ruth ties his record of 29 homers in a season
1929 1st airport hotel opens - Oakland Ca
1940 1st betatron placed in operation Urbana Il
1943 Diligenti quintuplets born in Buenos Aires Argentina
1944 Greenwich Observatory is damaged by World War II flying bomb.
1952 1st helicopter transatlantic flight began
1954 1st coml jet transport airplane built in US tested (Boeing 707)
1958 US troops occupy Lebanon stay 3 months.
1960 Orioles' Brooks Robinson goes 5 for 5 including the cycle
1975 Soyuz 19 and Apollo 18 launched; rendezvous 2 days later.
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();
?>