How to select different add to cart buttons?

Hello there,

I want to have an addtocart button that will be selected on the result of a query. I have stacked 5 addtocart buttons on top of each others and I would like the correct button to expand according to the result of the query. That seems the easiest way as I have only 5 products.
so if query returns id.article1 then addtocart1 button is selected and expands.
if query returns id.article2 then addtocart2 button is selected and expands.
I have added a field in my database that list the identity of the article as it appears in the datastore collection but I do not know the code to use with a button. For tables it is .rows = res.items and for images it is .src = item.field so what do we use in the case of an addtocart button that can not be connected to a database without coding?

Hope I am clear in my explanation. Best regards to all,

Thierry

In fact I was not thinking the problem correctly. I suppose I can use the result of 1 element that has already been sorted out but I have only images and tables that I can use as user input won’t do it. Would be something like:
if the the result of table1 ( only one field ) is ‘rouge’ then addtocartbutton1 expand
How do you code this kind of assertion and if the result is different how to make it pass to another value in the field? And how do you set the value for tables or images? May be there is another way to do this?
I have looked in forum but with no luck.
thanks so much to enlight me.
Thierry