How can the mysql_fetch_assoc function be utilized to avoid missing entries in a result set?

When using the mysql_fetch_assoc function to retrieve rows from a MySQL result set, it is important to iterate through all the rows to avoid missing any entries. One way to ensure all entries are processed is by using a while loop that continues fetching rows until there are no more left in the result set.

// Connect to the database
$conn = mysqli_connect("localhost", "username", "password", "database");

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

// Fetch rows using mysql_fetch_assoc in a while loop
while ($row = mysqli_fetch_assoc($result)) {
    // Process each row here
    echo $row['column_name'] . "<br>";
}

// Close the connection
mysqli_close($conn);