How to get percentage from mysql grading program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kkshansid
    New Member
    • Oct 2008
    • 232

    How to get percentage from mysql grading program

    i want to give grade to schools according to their student pass percentage
    just lile this kindly help me to find easiest way to do this

    Code:
    $sql1 = mysql_query("select count(studentid) as totstudent from result where schoolcode ='".$_GET['schoolcode']."'" );
       
       if(!$sql1) { echo mysql_error();}
        $sql3 = mysql_query("select count(pass_fail) as totpasstudent from result where schoolcode ='".$_GET['schoolcode']."' and pass_fail='p'" );
       
       if(!$sql3) { echo mysql_error();}
       
       $paspercentage=(totpasstudent/totstudent)*100
  • ziycon
    Contributor
    • Sep 2008
    • 384

    #2
    This is a very quick crude way to do it.
    Code:
    $sql = mysql_query("select count(studentid) as totstudent from result where schoolcode ='".$_GET['schoolcode']."'" );
    $row = mysql_fetch_array($sql);
    
    $sql2 = mysql_query("select count(pass_fail) as totpasstudent from result where schoolcode ='".$_GET['schoolcode']."' and pass_fail='p'" );
    $row2 = mysql_fetch_array($sql2);
    
    $paspercentag = round(($row2['totpasstudent']/$row['totstudent'])*100, 2);

    Comment

    Working...