How to open an image using Server side

Good morning

Im trying to open an image using server side script. i already have a code that change the image when i click it, but now i want that the image change when a binary value change and its gonna be like 3 variables.

something like this

if (var1){show image1}

else if (var2){show image2}

else if (var3){show image3}

else {show image4}

im waiting for any help and thank you for your information.

Best regards!