What are some common workarounds for outputting multiple records in a while loop in PHP?

When outputting multiple records in a while loop in PHP, one common workaround is to store the output in a variable and echo it outside the loop. This prevents multiple echo statements within the loop and can improve performance.

// Example of outputting multiple records in a while loop using a variable
$output = '';

while ($row = $result->fetch_assoc()) {
    $output .= '<p>' . $row['column_name'] . '</p>';
}

echo $output;