How can PHP and MySQL be used to create a top list of recipes based on their frequency of use in kitchens?

To create a top list of recipes based on their frequency of use in kitchens, we can use PHP to query a MySQL database that tracks the number of times each recipe has been used. We can then sort the recipes based on this frequency and display the top recipes in a list.

<?php
// Connect to MySQL database
$connection = mysqli_connect("localhost", "username", "password", "database");

// Query to get the frequency of each recipe
$query = "SELECT recipe_name, COUNT(*) as frequency FROM kitchen_usage GROUP BY recipe_name ORDER BY frequency DESC";

$result = mysqli_query($connection, $query);

// Display the top recipes
echo "<h2>Top Recipes:</h2>";
echo "<ol>";
while($row = mysqli_fetch_assoc($result)) {
    echo "<li>" . $row['recipe_name'] . " (Used " . $row['frequency'] . " times)</li>";
}
echo "</ol>";

// Close the connection
mysqli_close($connection);
?>