If my uniqueid and my image id are equal and it's active as the main image...it appears on the page.. but if a new image is uploaded i need the old image to be un active now and the new image to become the default active image... can someone help me with this php if else statement.

Here's my sql statement:

SELECT TOP 1000 [id]
  FROM [event].[AAA].[tracker]
  where active = '1'