since it is not in the loop, it will only show the result of the test for the first record.
To be honest, this is unsupported code, I can give you general idea of how to accomplish this, but it requires hand coding and good understanding of coding php in order to be successful, if you need more support than this in accomplishing this, I would suggest signing up for a premium support ticket where we could work with you in a one on one environment.