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
1517 Martin Luther posts his 95 Theses begins Protestant Reformation
1793 Execution of the Girondins at Paris during the Reign of Terror.
1864 Nevada admitted as 36th state.
1865 William Parson 3rd Earl of Rosse & maker of large telescopes dies
1922 Benito Mussolini (Il Duce) becomes premier of Italy.
1926 Erich Weiss better known as Magician Harry Houdini dies.
1952 1st thermonuclear bomb detonated - Marshall Islands
1956 Bkln NY ends streetcar service
1956 1st American to land by air at South Pole - GJ Dufek
1959 Lee Harvey Oswald announces in Moscow he will never return to US
1968 President Johnson orders a halt to all bombing of North Vietnam.
1980 Julian Nott sets world hot-air balloon altitude record (16 806 m).
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();
?>