I want entries in MySQL to be ordered by Date (fDate in my case) on my website. Here is the table structure:
The entries are read with this code:
$sql = "SELECT * FROM homework";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo "<br> Fach: " . $row["subject"] . "<br> Bis zum: " . $row["fDate"]. "<br>" . $row["hDesc"]. "<br>";
}
} else {
echo "0 results";
}
And this results in my Website looking like this:
Now I would like the output of every row ordered by date, so that the row with the date closest to the current one is displayed as the first. I'm new to MySQL and PHP, so how can this be done?