The problem is not in the foreach, but rather in how the template is being made and how to put <?php .... ?>
within the chain "breaks" the page:
<?php
...
$content = '
<h4>Title 1</h4>
<table>
<th>
<td>   Name    </td>
<td>   Title    </td>
<td>   ola   </td>
</th>
<tr>
<?php foreach($users as $user): ?>
<td><?php echo $user["id"]?></td>
<?php endforeach;?>
</tr>
</table>
';
(you can see how even the StackOverflow code formatter colors the foreach part differently after the first ?>
)
To solve this we should know what Template.php does (do you use any framework?) and find out how to create a loop with data inside it ... or simply generate the string directly before passing it to the Template (which will be much simpler and should work without problems):
$content = '
<h4>Title 1</h4>
<table>
<th>
<td>   Name    </td>
<td>   Title    </td>
<td>   ola   </td>
</th>
<tr>';
foreach($users as $user) {
$content = $content . '<td>' . $user["id"] . '</td>';
}
$content .= '</tr>
</table>
';
The final code would be like this (the foreach will not be needed at the end because it will have been fixed before).
<?php
require_once 'database.php';
$database_connection = database_connect();
$users = $database_connection->query('SELECT id FROM coffee')->fetchAll();
$title = 'Home';
$content = '
<h4>Title 1</h4>
<table>
<th>
<td>   Name    </td>
<td>   Title    </td>
<td>   ola   </td>
</th>
<tr>';
foreach($users as $user) {
$content = $content . '<td>' . $user["id"] . '</td>';
}
$content .= '</tr>
</table>
';
include 'Template.php';
?>