All pastes #280580 Raw Edit

nerk

public text v1 · immutable
·published 2006-12-16 00:29 UTC
rendered paste body
$mainquery = "SELECT id FROM record_choices"; //grab all record ids
$mainresult = mysql_query($mainquery) or die('Error : ' . mysql_error());

/* populate $_data array from your main query
while($row = mysql_fetch_array($mainresult, MYSQL_ASSOC))
{
   $_data[] = $row;
}


foreach($_data as $data) {  //loop through all the ids

	$query = "SELECT SUM(points) points FROM year_end_votes WHERE record_id = '".$data['id']."'"; //add up all scores for all occurences of id
	$result = mysql_query($query) or die('Error : ' . mysql_error());
	if($result && mysql_num_rows($result) == 1) {
			$row = mysql_fetch_assoc($result);
			$all_points = $row['points'];
			echo "Total score for record $value = {$all_points} <br>"; //print total score for record id
			} 
  
   }