Display image only once when variable true one or more times
I am new to php with mysql and have developed a code element that queries a record set of images. The images that are associated with my user are flagged as different image types and on my web page I want to display a flag just once if the image type is present one or more times in the record set. At the moment if I use the following code the flag appears as many times as the image type appears in the record set. Can someone advise how I limit the echo statement to be applied once only?
echo "<a href=\"form2.php?pid=$itemID\"><img src=\"images/flag.png\" width=\"120\" height=\"20\" border=\"0\" /></a><br />";