Do not "echo" $data. You need to put the data variable into your template after registering it. You add something like this at the bottom:
Code:
$templater->register('pagetitle', $pagetitle);
$templater->register('data', $data);
print_output($templater->render());
And this in your template:
Code:
<h2 class="blockhead">Title</h2>
<div class="blockbody">
{vb:raw data}
<div class="blockrow">