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
1737 Antonio Stradivari violin maker dies
1787 NJ becomes 3rd state
1813 British take Fort Niagara in the War of 1812
1849 William Bond obtains 1st photograph of moon through a telescope
1865 13th Amendment ratified slavery abolished
1898 Auto speed record set -- 63 kph
1915 Pres Wilson widowed the year before marries Edith Bolling Galt
1932 Chicago Bears beat Portsmouth Spartans 9-0 in 1st NFL playoff game
1945 Uruguay joined UN
1956 Japan admitted to the UN
1958 1st test project of Signal Communications by Orbiting Relay Equip
1958 1st voice from space: recorded Christmas message by Eisenhower
1958 Niger gains autonomy within French Community (National Day)
1961 India annexes Portuguese colonies of Goa Damao & Diu
1965 Borman & Lovell Splash down in Atlantic ends 2 week Gemini VII
1969 Britain abolished death penalty
1971 1st Candlelight Processional
1971 Diana Lynn dies at 45
1972 US began its heaviest bombing of North Vietnam
1973 Soyuz 13 launched into earth orbit for 8 days
1974 SF Visitors Center at City Hall opens
1980 Soviet Premier Alexei Kosygin suffered a fatal heart attack at 76
1985 UN Security Council unanimously condemns `acts of hostage-taking'
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();
?>