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
1543 England's King Henry VIII weds Catherine Parr (6th & last wife).
1689 Orangeman's Day-Battle of Boyne Protestant victory in Ireland
1812 US forces led by Gen. Hull invade Canada (War of 1812).
1862 Congress authorizes Medal of Honor
1927 Babe Ruth hits 30th of 60 HRs
1928 1st televised tennis match.
1933 Congress passes 1st minimum wage law (33› per hour).
1934 US Disciplinary Barracks on Alcatraz Island abandoned
1951 Yankee Allie Reynolds no hits Indians 1-0
1957 1st President to fly in helicopter - Dwight Eisenhower
1960 Echo I 1st passive satellite launched.
1960 USSR's Sputnik 5 launched with 2 dogs.
1962 Cosmonaut Popovich in space 1st time 2 manned craft in space
1967 5th Mayor's Trophy Game Mets beat Yanks 4-0
1975 Sao Tom‚ e Pr¡ncipe gains independence from Portugal (Nat'l Day).
1977 1st free flight test of Enterprise.
1978 Sun Bank Building opens
1979 Kiribati (Gilbert & Ellice Is.) gains independence from Britain.
1979 Minnie Ripperton dies of cancer at 30
1984 Geraldine Ferraro NY became 1st woman major-party VP candidate
1985 Drs discover a cancerous growth in Pres Reagan's large intestine
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();
?>