I just used "subject" as an arbitrary marker... it will be whatever column you are trying pass that you will need to put in there.
As far as I can see, your using an ID which I will guess is a number... if it is a number, you won't need to encode it as an ID number won't have any spaces or special characters.
By putting the if statement at the top, I just mean place it in your PHP BEFORE the HTML so it can then set the variable correctly when your form is added to the page.
I also made a mistake in the "if" statement... I accidentally put a colon instead of a semicolon after the else statement... just make sure you use a semicolon instead.
One more thing, if you have a column that actually contains a subject or name, you could pass that instead of ID through the URL and that way you'll actually have the name rather than just an ID number.
Let me know if you need any more help,