I built a page that brings data from my server into a wpdatatable. I then created 3 shortcodes: one to add the number of accounts, another to calculate an average of the ticket amount, and another one to add all transactions.
I'm experiencing a PHP fatal error for my website when the source table is empty. I think this is because the system is trying to attempt an average (Division by Zero).
When the source table is empty, the calculation functions do try to divide by zero, and that does cause an issue. What's the end result you'd like to see? Exclude empty rows so they're not included in the calculation or simply display some error message?
Hi team,
I built a page that brings data from my server into a wpdatatable. I then created 3 shortcodes: one to add the number of accounts, another to calculate an average of the ticket amount, and another one to add all transactions.
I'm experiencing a PHP fatal error for my website when the source table is empty. I think this is because the system is trying to attempt an average (Division by Zero).
Can you please help? These are the logs:
error 173.0.77.74:0] PHP Fatal error: Uncaught DivisionByZeroError: Division by zero in /nas/content/live/exampledashprod/wp-content/plugins/wpdatatables/source/class.wpdatatable.php:1560 Stack trace: #0 /nas/content/live/exampledashprod/wp-content/plugins/example-graphql-pull/src/shortcodes/DataTablesAggregate.php(86): WPDataTable->calcColumnFunction('Amount', 'avg') #1 /nas/content/live/exampledashprod/wp-includes/shortcodes.php(356): GraphCMSPull\shortcodes\DataTablesAggregate->output(Array, '', 'example_wpdatatabl...') #2 [internal function]: do_shortcode_tag(Array) #3 /nas/content/live/exampledashprod/wp-includes/shortcodes.php(228): preg_replace_callback('/\\[(\\[?)(example_w...', 'do_shortcode_ta...', '
Hello Alejandro
Thank you for reaching out to us.
When the source table is empty, the calculation functions do try to divide by zero, and that does cause an issue. What's the end result you'd like to see? Exclude empty rows so they're not included in the calculation or simply display some error message?
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables