By: Nino
Date: 2012-12-18
Time: 17:08
|
Multidimensional array and conditionalHi,
I'm trying to get a remind letter for each supporter of a charity with a table showing all payments of each one. I put the data from a database in an array like the following:
I would like to obtain letters like the following:
This is my tentative template:
and this my php code:
Unfortunately it doesn't work! Only the first two lines worked as expected. Can you help me, please? Thank you very much, Nino |
|||||
By: Skrol29
Date: 2012-12-19
Time: 00:51
|
Re: Multidimensional array and conditionalHi Nino,
Your PHP script is quite OK but the data are not simply structured, thus is it not convenient for the merging. I suggest that you build a variable which is a of the data but with a different structure, such as this one:
In your template, several thinks are wrong. You want to repeat each support on a new page, each Supporter having several Projects, and each project having several Contributions. So, for Supporters , you have to use a block instead of [onshow] tags. For example:
See the ODT example for merging with pages. The you have to merge the Projects names. This is done with sub-blocks. With the new data structure, you can use automatic sub-blocks (see the TBS manual). And you can also use automatic sub-blocks for Contributions. Is should be a sub block of Projects. |
|||||
By: Nino
Date: 2012-12-19
Time: 20:11
|
Re: Multidimensional array and conditionalHi Skrol29,
thank you very much for you kind and quick reply. Unfortunately I didn't succeeded to use new keywork, but restructing my data I did succeed to get half of my letter! I've modified my template:
I looked at the TBS manual, but I wasn't able to use blocks in order to get the list of the project inside the body of the letter and the contributions table. Can you help me? Greetings, Nino |
|||||
By: Skrol29
Date: 2012-12-20
Time: 01:20
|
Re: Multidimensional array and conditionalHi Nino,
What is the structure of your data now? |
|||||
By: Nino
Date: 2012-12-20
Time: 07:44
|
Re: Multidimensional array and conditionalHi Skrol29,
it's exactly the one you suggested me. I didn't change the PHP code. Nino |
|||||
By: Skrol29
Date: 2012-12-21
Time: 00:03
|
Re: Multidimensional array and conditionalHi,
Here is a plan that should work with the data structure I've submitted. The block names 's' has an automatic sub-block named 's_sub1'. Block 's_sub1' also has an automatic sub-block, it is named 's_sub1_sub1'. The following plan assumes that "s_sub1" and "s_sub1_sub1" fields are placed inside a Word table.
|
|||||
By: Nino
Date: 2012-12-21
Time: 17:43
|
Re: Multidimensional array and conditionalHi Skol29,
I tryed to use your template, but I got the following message:
I didn't succeed to get information about "w:tbl" and "w:tr" in the manual, so I changed the template in:
Now I get all the names of the projects, but not the dates:
Thank you for your kind help. Nino |
|||||
By: Skrol29
Date: 2012-12-22
Time: 10:20
|
Re: Multidimensional array and conditionalHi,
"w:tbl" and "w:tr" were for Ms Office, sorry for that. Your entities are ok. For dates, replace "sub2=dates" with "sub1=dates" and replace "s_sub1_sub2" with "s_sub1_sub1". Dates are not a second sub-block, they are a sub-sub-block. |
|||||
By: Nino
Date: 2012-12-22
Time: 11:17
|
Re: Multidimensional array and conditionalHi,
it works! Thank you very much for your help and your very useful TBS. Bye, Nino |