Category: Question and Answers
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Display multiple data from database in a 1 label (Text)

Issue

I want to combine two variables (first name and last name) into one label widget, but my current code is displaying them as two separate lines. I need a solution to display them as one line.

Resolution

To combine two variables in one label widget, you can use various methods. One way is to join the variables using the + operator inside the {{ }} binding like this:

{{ get_client.data[0].client_firstname + ' ' + get_client.data[0].client_lastname }}

Another way is to use two different bindings, separated by a space, outside the bindings like this:

{{ get_client.data[0].client_firstname }} {{ get_client.data[0].client_lastname }}

You can also use a template literal to combine the two variables like this:

{{ `${get_client.data[0].client_firstname} ${get_client.data[0].client_lastname }` }}

These methods will display the data in one line instead of two separate lines. It is important to note that the second method may not work if one or both of the variables are undefined.