What you want is the get_edit_post_link
function.
Usage:
echo '<a href="'.get_edit_post_link( $post_id ).'">edit</a>';
Your use of global $post
and the other issue is a separate problem, you should ask a new question and provide more details ( including the code for the template being used )