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
0780 BC 1st total solar eclipse reliably recorded by Chinese
1647 British army seizes King Charles I as a prisoner
1784 Mme. Thible becomes 1st woman to fly (in a balloon)
1792 Capt. George Vancouver claims Puget Sound for Britain
1812 La Territory officially renamed "Missouri Territory"
1850 Empire Engine Company No 1 organized
1896 Henry takes his 1st Ford through sts of Detroit
1919 US marines invade Costa Rica
1940 British complete miracle of Dunkirk by evacuating 300 -000 troops
1942 Battle of Midway begins 1st naval battle won in air
1944 1st submarine captured & boarded on high seas - U 505
1944 Rome liberated from Mussolini's Fascist armies
1946 Largest solar prominence (300 -000 miles) is observed
1947 Taft-Hartley Act approved despite Truman veto
1956 Speech by Khrushchev blasting Stalin made public
1957 1st commercial coal pipeline placed in operation
1970 Tonga gains independence from Britain (National Day)
1977 Violence during Puerto Rican Day in Chicago kills two
1982 Israel attacks targets in south Lebanon
1985 Supreme Court strikes down Alabama "moment of silence" law
1986 Jonathan Pollard spy for Israel pleads guilty
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();
?>