doupao5296 2015-06-28 16:06
浏览 46
已采纳

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

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, '.', '');
  • 写回答

2条回答 默认 最新

  • donglei1616 2015-06-28 16:09
    关注
    `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, '.', '');
        }
        ?>
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?