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
1266 Tynwald Day on Isle of Man.
1687 Isaac Newton's PRINCIPIA is published by Royal Society in England.
1753 Tynwald Day (Isle of Man)
1808 Battle of Buenos Aires.
1811 Venezuela-1st South American country to gain independence from Spain
1830 France invades Algeria begins a 40 year conquest
1859 Capt. N.C. Brooks discovers Midway Islands.
1865 William Booth founded Salvation Army in London
1935 1st Hawaii Calls radio program is broadcast.
1935 President FDR signs Natl Labor Relations Act
1937 Joe DiMaggio 1st grand slammer
1938 Herb Caen's 1st column in SF Chronicle
1940 Diplomatic relations broken between Britain & Vichy govt in France
1944 1st rocket airplane flown
1946 Louis Reard's Bikini swimsuit design debuts at a fashion show Paris
1947 Larry Doby signs with Cleveland Indians-1st black player in AL
1948 Carole Landis dies at age 29
1950 Law of Return passes allowing all Jews rights to live in Israel
1950 Pvt Kenneth Shadrick of Skin Fork WVa-1st US fatality in Korean War
1951 Junction transistor invention announced Murray Hill NJ
1962 Mantle hits 2 homers enroute to 4 consecutive homers
1971 Voting age lowered to 18 by 26th amendment.
1975 Cape Verdes Islands independence after 500 years of Portuguese rule
1978 Soyuz 30 is launched
1984 Supreme Court weakens 70-year-old `exclusionary rule'-evidence seized with defective court warrants can now be used in criminal trials
1986 Nancy Reagan cuts red white & blue ribbon reopening Statue of Liberty
1987 Australian Pat Cash wins Wimbledon-upsets No 1 seed Ivan Lendl
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();
?>