What's the error being displayed? I am not really too clear on what your problem is, but it sounds like you're passing the ID value as a GET value, right? Like:
mypage.com/index.php?ID=3
If that's the case, the appropriate way to write it would be:
<?php
if (isset($_GET['ID'])) {
$template = $_GET['ID'];
} else {
$template = 1;
}
?>
And then use $template instead of $ID (or whatever you want). Superglobals are teh evul.