Reputation:
I am trying to working on a student database, and have been getting problems to work out the percentage. I am getting lots of trouble with the posting of the code, so i posted line 123 and line 124.
$perca = $tota/ mysql_num_rows($result3);
echo number_format( $perca, 2, '.', '');
Upvotes: 0
Views: 1424
Reputation: 824
you will find this error because any value can not be divided by 0.
mysql_num_rows($result3) return 0, so you have such error. so put a condition that is mysql_num_rows($result3) !=0 then divide it.
Upvotes: 0
Reputation: 1814
`add if condition to avoid division by zero error`
<?php if(mysql_num_rows($result3)!=0) { $perca = $tota / mysql_num_rows($result3); echo number_format($perca, 2, '.', ''); } ?>
Upvotes: 1