You need to tell us what server-side scripting environment you are working in or whether you are using just straight HTML and relying on a pure Javascript solution.
If you are going the HTML/Javascript way... you need to collect the parameters off the URL, split the data pairs and confirm that you have something useful in a variable (that refers to the surname data).
Google for the following for details on how to do this (of course there are many resources that discuss this):
Parsing The Querystring with Javascript
Once the data is in a javascript variable, you can use the onload event to update the URL of the image (assuming you gave it an id) or you could document.write the image src "on the fly" as you build the page.
Google for getElementById and for document.write for more details on specific use of these commands.
Let us know how you get on.
Jeff