hello my code is like below

$result = mysql_query("select home_id,away_id from results");

$games=games_played(101,$result);
echo $games; // first echo


$games2=games_played(101,$result);
echo $games2; //second echo


and my function is


function games_played($team_id,$result2){

$counter=0;


while($row = mysql_fetch_array($result2)){
if($row["home_id"]==$team_id||$row["away_id"]==$team_id){
$counter++;
}

}

return $counter;
}

the thing is first echo statement writes 3 , on the screen , but the second one returns 0 .I know its because once i fetch $result in my function , pointer stays at the end of $results . How can i rewind my pointer ? and get 3 as a result of both echos?

thanks for your help and time.