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
1178 5 Canterbury monks report something exploding on the Moon
1630 Fork introduced to American dining by Gov Winthrop
1638 A lunar eclipse becomes the known astronomical event recorded
1788 Va becomes 10th state
1835 1st building constructed at Yerba Buena (now SF)
1868 FL AL LA GA NC SC readmitted to US
1876 Lt Col Custer & 7th Cavalry wiped out by Sioux & Cheyenne
1903 Yanks & White Sox end deadlocked at 6-6 in 18
1906 Architect Stanford White shot dead atop Madison Square Garden (which he designed) by Harry Thaw jealous husband of Evelyn Nesbit
1919 1st flight Junkers F13 advanced monoplane airliner
1929 Pres Hoover authorizes building of Boulder Dam (Hoover Dam)
1934 Yank pitcher John Broaca ties record by striking out 5 times
1938 federal minimum wage law guarantees workers 40› per hour
1942 British RAF staged a thousand-bomb raid on Bremen Germany (WW II)
1950 Korean Conflict begins; N Korea invades S Korea
1950 El Al begins air service
1951 1st color TV broadcast - CBS' Arthur Godfrey from NYC to 4 cities
1953 1st passenger to fly commercially around the world < 100 hours
1960 Walter Baade - astronomer - dies
1961 Yankee's Roger Maris hits his 40th of 61 HRs
1962 Yankee Jack Reed's 22nd inning HR wins a 7 hour game
1962 Supreme Court rules NY school prayer unconstitutional
1973 Udo Beyer of East Germany puts the shot a record 20.47 m
1973 John Dean begins testimony before Senate Watergate Committee
1975 Mozambique gains independence from Portugal (National Day)
1977 Roy C Sullivan of Va is struck by lightening for 7th time!
1977 Report of LBJ having cancer operation while Pres denied
1981 Supreme Court held male-only draft registration - constitutional
1982 Sec of State Alexander Haig Jr resigns Schultz replaces
1982 SF holds its 1st County Fair
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();
?>