While I can create a .rtf template and perform a simple text replacement from mysql/php for a known amount of variables....

In a similar way that arrays can be displayed in tables, and the length of the table depends on the number of row fetched, is there any way to do the same thing in a rtf document, so that if there is only 1 row of data, only this is displayed, but if there is 200 rows, then that section of rtf is ?looped? so that it displays 200 times with the appropriate data rows inserted???

Basically, I need a report in a word-type document using data from mysql - however the amount of data/rows varies considerably.

eg if only one peice of info fits critera and is returned - .rtf would show

Employee 17's name = Frank

But if lots of employees fit the criteria the .rtf would be looped to show
Employee 233's name is Bob
Employee 1065's name is Jill
Employee 1113's name is Sue
etc.

hope this makes sense!

Anything that could point me in the right direction would be much appreciated.

    There's several ways to do this. I think this way is the easiest to explain in a forum: Think of your RTF doc in sections. Split the sections and get it to the point where you can insert this dynamic section with whatever you like. If you can get this far, then half of the battle is over. The second trick is you'll need to loop through your recordset to identify all the people and their names. While you're looping through your recordset, you'll want to build the dynamic RTF section. You might use string concatenation or maybe get a little fancy with templates. The choice is yours. Then its a matter of reassembling the RTF sections to make one RTF doc.

      Thanks!
      Was struggling to get my head around this...kinda limited knowledge since ony new to php.
      Just tried doing a quick trial based on your info and am making progress!

      No doubt I'll be back when I hit the next hurdle!

      Thanks again. I just needed a push in the right direction.....

        Write a Reply...