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
1848 1st Women's Rights Convention Seneca Falls NY
1877 1st Wimbledon tennis championships held.
1880 SF Public Library starts lending books
1909 Neil Ball turns an unassisted triple play at 1st
1935 1st parking meters installed in Oklahoma City.
1939 1st use of Fiberglas sutures RP Scholz St Louis Mo
1949 Laos becomes associated state within French Union.
1955 Balclutha ties up at Pier 43 & becomes a floating museum.
1957 1st rocket with nuclear warhead fired Yucca Flat Nevada
1961 1st in-flight movie is shown (on TWA).
1963 Joe Walker in X-15 reaches 105 km.
1969 Mary Jo Kopechne dies at 28
1977 Yanks host 48th All Star Game NL wins 7-5
1978 Yanks start a 14 1/2 game comeback with 2-0 win
1979 Nicaragua Liberation Day; Sandinistas take over from Somoza.
1987 Don Mattingly sets AL record of extra base hits in 10 cons games
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();
?>