我一直收到此错误警告:除以零

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, '.', '');
`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, '.', '');
    }
    ?>

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.