What are the advantages of using mysql_fetch_assoc over mysql_result when fetching data in PHP?

When fetching data in PHP, using mysql_fetch_assoc over mysql_result is advantageous because mysql_fetch_assoc returns an associative array containing column names as keys, making it easier to work with the retrieved data. On the other hand, mysql_result only returns the value of a specific column in the current row, which can be less flexible and require additional code to handle.

// Using mysql_fetch_assoc to fetch data
$result = mysql_query("SELECT * FROM table");
while ($row = mysql_fetch_assoc($result)) {
    echo $row['column_name'];
}