What are the advantages of using mysql_fetch_assoc over mysql_fetch_array in PHP for database queries?

When fetching data from a MySQL database in PHP, it is generally recommended to use `mysql_fetch_assoc` over `mysql_fetch_array` for better performance and readability. `mysql_fetch_assoc` returns an associative array with column names as keys, making it easier to access specific fields by name. On the other hand, `mysql_fetch_array` returns a numerical array with both numeric and associative keys, which can be confusing to work with.

// Connect to database
$conn = mysqli_connect($servername, $username, $password, $dbname);

// Query database
$result = mysqli_query($conn, "SELECT * FROM table");

// Fetch data using mysql_fetch_assoc
while ($row = mysqli_fetch_assoc($result)) {
    // Access fields by column name
    echo $row['column_name'];
}

// Close connection
mysqli_close($conn);