Creating a List by looping 2 database Querys

So, I need to create a list where the data is in two tables. Example list:

Chapter 1

  • Person A
  • Person B
  • Person C
    Chapter 2
  • Person 1
  • Person 2
  • Person 3

So normally I would run a PHP database query to table one to get the list of “Chapters” and then do a while loop and hit the database table with the “Persons” in each pass of the loop.

My question is: How do I accomplish this in Wappler?

Thanks for any help.

your description does not include much detail so hard to give a specific answer on the info given but you seem to be describing some sort of table intersection? if so then it can probably be done with a join. try describing what data you have and what you want to achieve rather than what you would have done previously.

Do the following

  1. You first create your main query

  2. Uncheck output option for the query

  3. Then you create a repeat and set as an expression the first query

  4. Then pick the values from the first query that you want to use in the second query

  5. Create the second query and use as filter the value/values that you imported from the first query

  6. Check the output option

Inside AppConnect use the repeat for retrieving the values of the query

1 Like

you use a single query on the server side that have the id of the chapters and the persons table
then on the client side you do a group by the id of the chapters


That helped a lot however, I’m not quite there. I was able to create the Server Action and have connected it to the page. I’ve got a row with two columns and I can get the first column to show the “Chapter” names. In the second column I can get only “person” names for one of the chapters to display. I don’t think I’m using the “DIV Repeat Children” components correctly. I would like the “Chapter” names to be headers with the names listed below. Can you nest the DIV Repeat Children components?

For the first query uncheck the output option
Pass any of the values from the first query into the repeat
For the ServerConnectAction use the repeat as an expression
This way you will be able to display your data the way you want

More Progress. I now have the chapters as a heading and one person is showing up under each chapter. I appears that the list of persons is only looping once.


Did you make the right selection for the ServerConnectAction
Can you post a screenshot?

So, I’m really new to Wappler. I might not know if I am sure of the ServerConnectAction.

remove the [0] from the query inside your code

Well, still only looped once and now there are no values from the second query showing. Should there be something in the [ ]?

You need to nest a second repeat region inside the one you already have (use as expression the nested query), then bind the info inside it.
It will repeat the child elements for each parent item.