I am trying to get a percentage of a php variable from another, for example i have two databases of information, the first database is full of unidentified information. The second database is full of the information we have identified. and so i want to work out dynamically the percentage of the total information identified.
Below is a php function to work out a percentage,
//TOTAL ENTRIES INTO Table 1 FOR total data
$result = mysql_query( "SELECT * FROM table1" );
$num_total = mysql_num_rows( $result );
//TOTAL ENTRIES IN Table 2 FOR THE PERCENTAGE
$result = mysql_query( "SELECT * FROM table2" );
$num_amount = mysql_num_rows( $result );
function percent($num_amount, $num_total) {
$count1 = $num_amount / $num_total;
$count2 = $count1 * 100;
$count3 = 100 - $count2;
$count = number_format($count3, 0);
echo $count;
}
Both queries return the correct information of the total number of rows counted in the database, however the count variable does not return any information.
Any ideas or suggestions would be appreciated.
Thanks
Stan