The problem is like this: i want to have some stats regarding the members of each department subscribed to a newsletter. The stats must be in absolute value(which I have already done), and in percentage value.
What i have done: I only have the php code for displaying the stats in absolute value.
mysql_select_db(aiesecis);
$query = "SELECT dep.department, COUNT(*) AS total FROM main, dep WHERE main.iddep = dep.id GROUP BY department";
$result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error());
if ($myrow=mysql_fetch_array($result)) {
do {
$total[] = $myrow["total"];
$department[] = $myrow["department"];
}while ($myrow=mysql_fetch_array($result));
}
- The question: .How can i get another array with the percentage values? I have also tried to work in the sql phrase, but as mysql doesnt support nested interogations, i havent succeeded. How cand i divide the values from one array to another single value (the total)? Is it possible in sql, or should i work to the arrays?
Thanks for any support