What are some common pitfalls when trying to display data in a table using PHP?

One common pitfall when displaying data in a table using PHP is not properly escaping the data, which can lead to security vulnerabilities like SQL injection attacks. To solve this issue, always use prepared statements or escape the data using functions like `htmlspecialchars()` before outputting it in the table.

// Example of escaping data before outputting in a table
$data = "<script>alert('XSS attack');</script>";
echo "<table>";
echo "<tr><td>" . htmlspecialchars($data) . "</td></tr>";
echo "</table>";