When should mysql_fetch_assoc, mysql_fetch_row, or mysql_fetch_array be used in PHP?
When fetching data from a MySQL database in PHP, you can use mysql_fetch_assoc to retrieve a row as an associative array with column names as keys, mysql_fetch_row to fetch a row as a numerical array, or mysql_fetch_array to fetch a row as both an associative and numerical array. Use mysql_fetch_assoc when you want to access data by column names, mysql_fetch_row when you only need numerical indices, and mysql_fetch_array when you need both options.
// Example of using mysql_fetch_assoc to fetch data as an associative array
$result = mysql_query("SELECT * FROM table");
while ($row = mysql_fetch_assoc($result)) {
echo $row['column1'] . ' - ' . $row['column2'] . '<br>';
}