From Server Connect DB Query to Array

Hi,

I have a form in which the user insert tags as per @Teodor tutorial:

The tags are inserted into an input form and sent to the Server Connect.

on the second page, where the query is made, the saved values are shown in the table cell as they are in the DB, i.e. a comma delimited list:

value1, value2, value3, value4 …

I wish I could show comma-delimited values on various buttons, kind of like in Theodor’s example or as per first image (where inserting the tags).

Any suggestions? should I set new array in the page ?

Thank you very much

Roberto

Not a great idea to store them comma separated, but if you insist to do so, then on the page you can split them and add a repeat like:

<button dmx-repeat:repeat1="your_binding.split(',')">{{$value}}</button>

Which is the best approach to save them on a DB?

Store them separately, a new record per each value.

Schermata 2021-03-11 alle 17.13.38

then instead to store them on “subject” field make a table for tags and a “middle” table connecting chat_id with tags_id ?

there are just keywords for each single chat. But I see your point.

You can just use two tables, one for the chat_id and another table for the tags, related to a specific chat_id from the first table.
Two table approach is really easier to maintain than a comma separated values.

1 Like

OK thank you .

It is first time working with arrays etc… will study deeper…

thank you Teodor!