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
1579 Cornerstone is laid for Tycho Brahe's Uraniborg observatory
1609 Venetian senate examines Galileo Galilei's telescope
1709 1st known ascent in a hot-air balloon by Father Bartolomeu de Gusmao of Portugal (indoors!)
1814 Peace negotiations begin in Ghent Belgium
1843 Natal (in South Africa) is made a British colony
1864 Red Cross Anniversary
1900 1st Davis Cup tennis matches held in Boston
1920 Tigers beat Yanks 1-0 in shortest AL game 73 minutes
1929 Salem Oregon airport dedicated
1937 Bonneville Dam on the Columbia River begins producing power
1940 Battle of Britain began as Germany launched air attacks
1963 Great Train Robbery in England
1972 Yanks sign a 30 year lease with NY City
1978 US launches Pioneer Venus probe
1980 LBV Conference Center & Club Lake Villas open
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();
?>