如何在PHP中获得平均分数

i want to calculate average on run time by totalscore/totalevaluatedcalls which is 100.how can i did it with php...and after table here is my code.any one can help me in this regard .total evaluated calls are the count of emp id from db.

empid    agentname    totalevaluatedcalls     totalscore     avaragescore
=========================================================================
1       xyz            2                      200             100


total evaluatedcalls query
========================== 

foreach($dbh->query("SELECT COUNT(*) as cnt FROM eval where empid=$empid") as $test) {  
    echo "<table ><tr ><td style='border: 0px; '>" . $test['cnt'] . "</td></tr></table>";
}

?>

total score query
========================== 


foreach($dbh->query("SELECT SUM(totalscore) as cnt FROM eval where empid = $empid") as $leavecount) {  
    echo "<table ><tr ><td style='border: 0px; ' >" . $leavecount['cnt'] . "</td></tr></table>";
}
?>

Combine this queries

foreach($dbh->query("SELECT COUNT(*) as cnt, SUM(totalscore) as totalscore, SUM(totalscore)/SUM(totalevaluatedcalls) as averagescore
                FROM eval 
                where empid= $empid 
           ") as $test) 
                     {  
echo "<table ><tr ><td style='border: 0px; '>" . $test['cnt'] . "</td><td style='border: 0px; '>" . $test['totalscore'] . "</td><td style='border: 0px; '>" . $test['averagescore'] . "</td></tr></table>";    

            }

use query as

foreach($dbh->query("select count(*) as cnt,sum(totalscore) as tot from eval where empid=$empid") as $data)
{
   $avg=($data['cnt']/$data['tot'])*100;
}