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
1806 Buenos Aires captured by British
1838 Queen Victoria is crowned
1844 Mormon leaders Joseph & Hyrum Smith killed by a mob in Carthage
1847 NY & Boston linked by telegraph wires
1867 Bank of Calif opens doors
1929 1st color TV demo - NYC
1934 Federal Savings & Loan Association created
1940 End of USSR experimental calendar
1942 FBI captures 8 Nazi saboteurs from a sub off NY's Long Island
1944 Cherbourg - France captured by Allies
1950 Pres Truman orders Air Force & Navy into Korean conflict
1954 CIA-sponsored rebels overthrow elected government of Guatemala
1955 1st automobile seat belt legislation enacted Illinois
1957 500 people killed by Hurricane Audrey in coastal La & Tx
1960 Chlorophyll "A" synthesized Cambridge Mass
1962 NASA X-15 flies at 4105 mph
1963 Robert Rushworth in X-15 reaches 87 km
1963 Pres Kennedy spent 1st full day in Ireland
1966 4th Mayor's Trophy Game Yanks beat Mets 5-2
1973 John W Dean tells Watergate Committee about Nixon's `enemies list'
1977 5-4 decision Supreme Court decides to let lawyers advertise
1977 Djibouti gains independence from France (National Day)
1978 Soyuz 30 launched
1982 4th Space Shuttle Mission - Columbia 4 launched
1983 Soyuz T-9 carries 2 cosmonauts to Salyut 7 space station
1983 Balloonists Maxie Anderson & Don Ida died during a race
1984 Supreme Court ends NCAA monopoly on college football telecasts
1986 World Court rules US aid to Nicaraguan contras illegal
1987 Supreme Court Justice Powell retires
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();
?>