in reply to displaying an image

During your troubleshooting, did you print out the result of this string to make sure, e.g. after the substr(), that the path is correct for $courselocation/images/$value before placing it within the <IMG> tag?
--newbie00