To make it easy for you to understand what is happening. I think that you code as the first line is, then I will try to explain what is happening.
echo "<table class="table1">";
// That does not echo what you want it to echo. The reason is that it starts with
echo "table class=" // That is enough for the echo, it have one " to start and one " to end. When you continue something goes wrong, the rest of the row is not interperated correctly and if you set error_reporting(E_ALL) you will probably see a error message.
The reason for the problem is simply that you try to use " both to show what will echo and inside it. Try to change between " and ' instead, like one of the rows below:
echo "<table class='table1'>";
echo '<table class="table1">';