What I am trying to check is whether fields are empty or not from an1 to an30. The values retrieved from database are then put in the row which is blank. That is why I am using IF ELSE IF statement. I am not understanding why this is happening. My code should stop after satisfying one if condition. It just also moves on to the next one.