You are on the right way.
<a href="<?php print get_permalink($id_of_the_post_you_want_to_link_to); ?>#......">Link</a>
the_permalink()
makes only sense in a post loop. But get_permalink()
is accepting a parameter of another post and gives you its permalink.