relay and switch problem

For future reference:-

section on the right is to represent the relay board, (it has two blocks of pins). It has it's own power supply

There is no common ground shown. You must have one or else it would not have worked. The image is too small to see and people here don't like using third party web sites that require you to log in. Just attach your image, if you don't know how then please read this:-
How to use this forum

The actual code could have been written in about 9 lines if you learn about arrays.