***Apologies, answered my own question. No need for the while loops.
So I have the below queries that are working great; however, now I want to create a calculation based on them both, for example:
$cache['vote']['points']['maletofemale'] = $male_result['value_male'] / $male_result['value_male'] + $female_result['value_female'];
This would calculate the percentage of men to women who voted on the node, and then I would do the same for women to men. However, it seems that the second query call erases the first call even if I move it within the "while (" statement. Is it possible to maintain the information from "$male_result['value_male']" when making the second call to the DB?
<?php
/**
* Implementation of hook_votingapi_results_alter().
*/
function calchook_votingapi_results_alter($cache, $content_type, $content_id) {
// Pulling in male or female from personal profile
$sql = "SELECT v.tag, v.value_type, ";
$sql .= "COUNT(v.value) as value_male ";
$sql .= "FROM {votingapi_vote} v ";
$sql .= "INNER JOIN {profile_values} p ";
$sql .= "ON v.uid=p.uid ";
$sql .= "WHERE v.content_type = '%s' AND v.content_id = %d AND v.value_type IN ('points') AND p.value IN ('male') ";
$sql .= "GROUP BY v.value_type, v.tag";
$male_prelim = db_query($sql, $content_type, $content_id);
while ($male_result = db_fetch_array($male_prelim)) {
$cache[$male_result['tag']][$male_result['value_type']]['male'] = $male_result['value_male'];
}
$sql = "SELECT v.tag, v.value_type, ";
$sql .= "COUNT(v.value) as value_female ";
$sql .= "FROM {votingapi_vote} v ";
$sql .= "INNER JOIN {profile_values} p ";
$sql .= "ON v.uid=p.uid ";
$sql .= "WHERE v.content_type = '%s' AND v.content_id = %d AND v.value_type IN ('points') AND p.value IN ('female') ";
$sql .= "GROUP BY v.value_type, v.tag";
$female_prelim = db_query($sql, $content_type, $content_id);
while ($female_result = db_fetch_array($female_prelim)) {
$cache[$female_result['tag']][$female_result['value_type']]['female'] = $female_result['value_female'];
}
}