I’m not sure of the terminology for what I’m asking for!
I have a table with multiple entries which I have a select query getting the records I require. If any of the records have Yes in one of the fields I need to echo “Yes”. Most of the records will have a no, in which case I need to echo “No”.
I’m trying to amend old code without having to re-write the entire site so if anyone can help that would be great.
I think there’s a couple of ways to read this - the solution from @chorn above will do exactly as you say you want - if any of the records contains “Yes” in the “Freefrom…” column then it will display “Yes” at the bottom of the list.
But, do you want to display a single “yes” to show that one of the names in the list has that status, or do you want to display the “Yes” alongside the item name, to indicate which specific item names have that status? If this is what you want, then simply modify this bit of code:
I need the result to stay as No even if the following record in the loop is Yes.
e.g.
table1
id | FreeFromArtificialColours
1 | Yes
2 | Yes
3 | No
4 | Yes
The result should then be No as 1 of the records is No even though there are records after this.
From what I understand your solution is setting a variable and basing the result on the last record in the loop.