1

I am displaying the meeting report from PHP Mysql. For Example there will be two fields in database as Department Name and Members. Suppose Mechanical Department has 20, Computer Department has 15, Civil Department has 10. i want to display total count. 20 + 15 + 10 will be 45 . i am using like this code

<?php
$i=1;
while($rows=mysql_fetch_array($result)){
?>

<?php echo $rows['att_report']; ?>

<?php
    $i++;
}
?>

i need two conditions. first one is to find total count. and percentage.

only chande
  • 99
  • 2
  • 10
  • 1
    If you can, you should [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). [These extensions](http://php.net/manual/en/migration70.removed-exts-sapis.php) have been removed in PHP 7. Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [PDO](http://php.net/manual/en/pdo.prepared-statements.php) and [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) and consider using PDO, [it's really pretty easy](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Nov 30 '15 at 19:56
  • 1
    Use a `COUNT` and `GROUP BY` in your SQL statement to get the results you're looking for. – Jay Blanchard Nov 30 '15 at 19:57
  • what is the SQL query you are using? – Ada Lovelace Dec 01 '15 at 15:09

0 Answers0