All pastes #215452 Raw Edit

Stuff

public text v1 · immutable
#215452 ·published 2006-10-22 16:53 UTC
rendered paste body
function GetVoteArray(&$VoteArray)
{
	$command1 = "SELECT DISTINCT photo,member,category FROM photo_vote";
	$result1 = mysql_db_query("db_member_info",$command1);
	
	if($result1!= FALSE)
	{
	
		while($array1 = mysql_fetch_array($result1))
		{
			$photo_tmp[$counter] = $array1['photo'];
			$member_tmp[$counter] = $array1['member'];
			$category_tmp[$counter] =$array1['category'];
			$command2 = "SELECT photo,member,category, AVG(vote),COUNT(vote) FROM photo_vote
				WHERE photo='$photo_tmp[$counter]' AND member='$member_tmp[$counter]' AND category='$category_tmp[$counter]' GROUP BY photo,member,category";
				
			$result2 = mysql_db_query("db_member_info",$command2);
			if($result2!= FALSE)
			{
				while($array2 = mysql_fetch_array($result2))
				{
					$VoteArray[] = array('photo' => $array2['photo'],
										'member' => $array2['member'],
										'category' => $array2['category'],
										'avg_vote' => $array2['AVG(vote)'],
										'vote_nr'  => $array2['COUNT(vote)']);
				}
			}
			else
			{
				exit ("Incorrect query " . mysql_error());
			}
		}
	}
	else
	{
		exit ("Incorrect query " . mysql_error());
	}
}