How to get node.tpl.php to display different content for different nodes?
I don't See any node id in your code. If all you want is to have PHP generated output for an URL, define the path with hook_ menu() and just return the generated HTML from the call back method.