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
1716 1st lion to be exhibited in America (Boston)
1778 Capt Cook discovers Maui (Sandwich Islands)
1789 1st natl celebration of Thanksgiving
1793 Republican calendar replaces Gregorian calendar in France
1825 1st fraternity Kappa Alpha formed at Union College (Schenectady)
1832 1st horse drawn American street car -NYC- fare: 12›
1865 Alice in Wonderland published
1868 1st baseball game played in enclosed field in SF at 25th & Folsom
1883 Sojourner Truth abolitionist women's rights advocate dies
1885 1st Meteor photograph
1895 Hawaiian Sugar Planters Assn formed
1940 Nazis force 4.5 mil Warsaw Jews to live in walled ghetto
1949 India adopts a constitution as a British Commonwealth Republic
1950 China enters Korean conflict
1962 1st recording session under the name Beatles
1965 France launches 1st satellite a 92-pound A1 capsule
1966 1st major tidal power plant opened at Rance estuary France
1973 Nixon's personal sec Rose Mary Woods told a federal court she accidentally caused part of 18-minute gap in a key Watergate tape
1975 Fed jury found Lynette Fromme guilty of attempted assassination
1980 Rachael Roberts dies at age 53
1982 Yasuhiro Nakasone elected PM of Japan succeeding Zenko Suzuki
1982 Clyde King named Yankee manager
1985 23rd Space Shuttle Mission - Atlantis 2 is launched
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();
?>