How can the ORDER BY clause in MySQL be used to sort data by multiple columns in PHP?

To sort data by multiple columns in MySQL using the ORDER BY clause in PHP, you can simply list the columns you want to sort by separated by commas. This will first sort the data by the first column specified, and then by the second column if there are duplicates in the first column.

$query = "SELECT * FROM table_name ORDER BY column1, column2";
$result = mysqli_query($connection, $query);

while($row = mysqli_fetch_assoc($result)) {
    // Output or process the sorted data here
}