What are the common issues with displaying data in tables in PHP and how can they be resolved?

Issue: One common issue with displaying data in tables in PHP is not properly escaping user input, which can lead to security vulnerabilities like SQL injection attacks. To resolve this issue, you should always sanitize and escape user input before displaying it in a table.

// Example of sanitizing and escaping user input before displaying in a table
$user_input = "<script>alert('XSS attack!');</script>";
$sanitized_input = htmlspecialchars($user_input);

echo "<table>";
echo "<tr><td>" . $sanitized_input . "</td></tr>";
echo "</table>";