I am not sure what your problem is but I know my solution will work (PROVIDED THAT your code is correct).
So what you have to is copy your code in the begining of file yourboard/global.php right AFTER line:
Then you have to edit your code so that it will NOT echo anything or send any information to the user. So delete all your echo commands. Instead of echoing while the code is parsed, put the information inside a variable like:
$my_variable.=" <td width=\"20\" bgcolor=\"#F0F0F0\" align=\"center\">";
$my_variable.="<a href=\"$url/index.php?ct=general&md=details&id=$row->idnum\">$row->title</a></font></td>";
etc.
then put $my_variable inside any template you like (header for you)
If you get "headers already sent error" after modification it means that while editing your code you miss a part which echos a text or sends a piece of information to user, so make sure to remove that part and this will do the trick.