What I want to do:
generate rtf documents fusionning data from MySQL and and a rtf template where I put stuffs like "<#NAME#>".
I want to do it all dynamically: I don't want to write a script specific to each template with an association between tag names and SQL fields in my queries.
So:
1- I strore my templates: filename, ...
2- I store my queries in a MySQL table (fields: select, from, where, groupby, orderby and limit); these queries can use some PHP variables ($DATE,$ITEM_ID,...) which enable to retrieve exactly the data I want.
3- A template is linked to none or several queries
4- A template is linked to none or several tags-SQLfield pairs (here is what is at stake, I'll come back later on this)
When I want to generate the doc, here how it goes:
1- Load the appropriate template and all the queries
2- evaluate the queries as:
eval("\$the_query=\"SELECT $select FROM $from WHERE $where ...\";");
3- then pass the queries to retrieve data, say in $data (array)
4- retrieve the tag-SQLfield pairs linked to the template, say in $tag (matrix)
5- while there is row in $tag, replace the tag $tag["name"] by $data[$tag["field"]]
...and that's it.
Now let's come back to our point:
I'd like to make a user interface page so he can make the association tag-SQLfield.
For a given template: I parse it, retrieve tags, fill my table (fields: tag, SQLfield(NULL at start) ). then I have to retrive SQLfields from the queries linked to my template to make a dropping lists and propose them for choice in front of each tag name.
The problem is that when doing this at this time, I have no idea of what correct parameters ($DATE, $ITEM_ID,...) could be, since it depends on the template I'm treating.
I'd like to be able to retrive SQLfields, NOT without requesting MySQL, BUT without any data in my database.
I don't know yet if MySQL has included stored queries (with parameters). It may be solution if so, wouldn't it?
Thank you again.
P.S.:If you want I can send you a view of the user interface stuff, so can make you a more visual idea