From 1caad26fb98cdcc5803dd5f9c32053b04d480e9e Mon Sep 17 00:00:00 2001 From: Madeorsk Date: Sun, 26 Aug 2018 12:06:30 +0200 Subject: [PATCH] Fixed division by zero. --- views/results.php | 2 +- views/svg/results.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/views/results.php b/views/results.php index 96453dd..bc1e9a0 100644 --- a/views/results.php +++ b/views/results.php @@ -12,7 +12,7 @@ foreach ($poll->options as $option) votes ?> label ?> - votes / $total_votes, 3)*100 ?>% + votes / $total_votes, 3)*100 ?>% diff --git a/views/svg/results.php b/views/svg/results.php index 047dfa7..4f2a14b 100644 --- a/views/svg/results.php +++ b/views/svg/results.php @@ -9,7 +9,7 @@ foreach ($poll->options as $option) $options_percentages = []; foreach ($poll->options as $option) - $options_percentages[] = $option->votes / $total_votes; + $options_percentages[] = ($total_votes == 0) ? 0 : $option->votes / $total_votes; function percentage_pos_x($r, $percentage) { return round($r * sin(2 * M_PI * $percentage), 2); }