How can the ORDER BY clause be properly used in a SQL query to display database results in descending order based on a specific column?
To display database results in descending order based on a specific column in a SQL query, you can use the ORDER BY clause followed by the column name and the keyword DESC for descending order. This will arrange the results in reverse order based on the specified column.
$query = "SELECT * FROM table_name ORDER BY column_name DESC";
$result = mysqli_query($connection, $query);
// Loop through the results
while($row = mysqli_fetch_assoc($result)) {
// Output the results
echo $row['column_name'] . "<br>";
}