I've build an example for you. It contains two tables: The first can have multiple rows. The second is repeated on a newly created page for each row of the first table and is filled with the values of the related row.
It needs at least two separate pages, each with a table, a conditional break of the second table and two functions in a script object to make it work. You can access the samle here: Dateien freigegeben - Acrobat.com