If you've injured your nail and nail bed and the nail becomes detached from the nail bed there's no way to reattach the nail to the nail bed.
What you'll need to do is cut the nail and then let a new nail slowly grow back into place which can take up to 6 months from the time you lost your first nail to the time a new nail will grow back.