Hello
i guess, my problem is trivial, but i still need help ...
What i want is this: display values from a DB in a simple table and then export this table to csv by clicking a 'Submit'-button.
So i did this:
- i put a 'DB Read' in the 'On load'-section, i enable it, choose the DB-Table, enable Multi read, Enable Model ID, name the Model ID 'Agenda' and select the desired fields.
- in the 'On found'-section of the 'DB Read' i put 'HTML (Render Form)'. There i display the values with this code
- with this, the table is displayed correctly. Now i want to save this table to csv, so i put a 'CSV Export' in the 'On submit'-section. I enable it, choose no table and put 'Agenda' in the Data Path.
- If i click submit, i get a csv-file with this content: 'Notice: Undefined variable: data in ...\csv_export.php on line 124. Warning: array_walk() expects parameter 1 to be array, null given in ...\csv_export.php on line 130'
What am i doing wrong?
Thank you!
Daniel
i guess, my problem is trivial, but i still need help ...
What i want is this: display values from a DB in a simple table and then export this table to csv by clicking a 'Submit'-button.
So i did this:
- i put a 'DB Read' in the 'On load'-section, i enable it, choose the DB-Table, enable Multi read, Enable Model ID, name the Model ID 'Agenda' and select the desired fields.
- in the 'On found'-section of the 'DB Read' i put 'HTML (Render Form)'. There i display the values with this code
<table>
<?php
foreach ( $form->data['Agenda'] as $e ) {
echo "<tr>
<td>{$e['datum1']}</td>
<td>{$e['titel']}</td>
<td>{$e['ort']}</td>
</tr>";
}
?>
</table>
and i have a Submit-Button.
- with this, the table is displayed correctly. Now i want to save this table to csv, so i put a 'CSV Export' in the 'On submit'-section. I enable it, choose no table and put 'Agenda' in the Data Path.
- If i click submit, i get a csv-file with this content: 'Notice: Undefined variable: data in ...\csv_export.php on line 124. Warning: array_walk() expects parameter 1 to be array, null given in ...\csv_export.php on line 130'
What am i doing wrong?
Thank you!
Daniel
Hi Daniel,
The data from the DB Read in the On Load event isn't automatically passed to the On Submit event so you need to re-link the CSV Export to the table to get the data to export.
Best wishes
Bob
The data from the DB Read in the On Load event isn't automatically passed to the On Submit event so you need to re-link the CSV Export to the table to get the data to export.
Best wishes
Bob
Thank you very much, Bob
Do i have to place a DB Read also in the On Submit, or is there another way to re-link the CSV Export to the table?
Daniel
Do i have to place a DB Read also in the On Submit, or is there another way to re-link the CSV Export to the table?
Daniel
Hi Daniel,
I think that you can link the CSV Export action directly to the table.
Bob
I think that you can link the CSV Export action directly to the table.
Bob
Hi Bob
unfortunately i have very little knowlegde in programming, so i have no idea, how to make this link to the table. Can you give me a hint? Do i need some custom code? Where must i place it and what should be in it?
Thank you!
Daniel
unfortunately i have very little knowlegde in programming, so i have no idea, how to make this link to the table. Can you give me a hint? Do i need some custom code? Where must i place it and what should be in it?
Thank you!
Daniel
Hi Daniel,
Open the settings in the CSV Export action, find the Table Name drop-down (just under Enabled) and select the table.
Bob
Open the settings in the CSV Export action, find the Table Name drop-down (just under Enabled) and select the table.
Bob
Hi Bob
This links the CSV Export to the whole DB table and exports all the values in it. This is not what i need. I want to export the values from the HTML-table, as i defined it in the DB Read/On found-section. Can i do this?
Daniel
Open the settings in the CSV Export action, find the Table Name drop-down (just under Enabled) and select the table.
This links the CSV Export to the whole DB table and exports all the values in it. This is not what i need. I want to export the values from the HTML-table, as i defined it in the DB Read/On found-section. Can i do this?
Daniel
Hi Daniel,
Sorry, I missed what you had asked. You were right with the Data Path setting.
Please try setting Site Error Reporting to System Default or to None in the Site Global Configuration. That should stop the PHP Warnings from displaying and will hopefully let the export run correctly.
Bob
Sorry, I missed what you had asked. You were right with the Data Path setting.
Please try setting Site Error Reporting to System Default or to None in the Site Global Configuration. That should stop the PHP Warnings from displaying and will hopefully let the export run correctly.
Bob
Hi Bob
Thank you. I set Error Reporting to None. Now the PHP Warning has disappeared, but the exported CSV-File ist empty, with a size of 0 bytes.
Daniel
Thank you. I set Error Reporting to None. Now the PHP Warning has disappeared, but the exported CSV-File ist empty, with a size of 0 bytes.
Daniel
Hi Daniel,
Please add a Debugger action after the CSV EXport action and submit the form - you may get a very long output - that should let you see the values in the $form->data['Agenda'] sub-array and check that they are what you expect.
Bob
Please add a Debugger action after the CSV EXport action and submit the form - you may get a very long output - that should let you see the values in the $form->data['Agenda'] sub-array and check that they are what you expect.
Bob
Hi Bob
I'm sorry, that this finds no end. I added the Debugger and enabled it. But i get no output at all. All that's happening is that a empty CSS-File ist created.
Daniel
I'm sorry, that this finds no end. I added the Debugger and enabled it. But i get no output at all. All that's happening is that a empty CSS-File ist created.
Daniel
This topic is locked and no more replies can be posted.