MergeField with userfunction
I have a problem understanding MergeField with a MySQL-query and a userfunction.
I have a database which contains records with fields, which I want to modify before output.
May be, I am on a total wrong way. I think, can use a function, which makes the modification.
First question: Must I call the MergeField-call before or after the MergeBlock-Call?
Second question: What is the correct syntax calling my function?
I looked for e complete example, but I dont find one.
Here is my code:
And here is the template test.htm:
Many thanks for help.
Re: MergeField with userfunction
In your snippet, the line with MergeField() will have no effect because there is no "table_data" fields left in the template. They all were already merged by MergeBlock().
If you want to catch the data before to merge them. They are two possibilities.
1) Fetch yourself the SQL data in a php variable such as $data. Change the data. Then merge the variable with a MergeBlock().
2) Use parameter "ondata" on the block. This enables you to define a custom PHP function that can read and modify each records before it is merged.