Hi, I am having a problem with my code, what is happening is i am displaying members from a users table and for every user in the foreach loop i am checking to see if any of there qualities match with the user that is running the search. The way it matches is it checks about 25 fields and if there is a match then it adds 1 for every match. Then it adds all the 1's up and assigns that to a variable to use. The problem i am having each time it loops it adds the previous results and the current results and keeps doing that through the loop. What i need to do is for it not to add the previous entrys so that the result is correct for each users. $sql = mysql_query("select * from users WHERE $stored AND status='active'"); $countrows = mysql_num_rows($sql); // get all the products from the table $result = array(); //$e=0; $resultsi = mysql_query("SELECT * FROM users WHERE id = '$_COOKIE[id]'"); $rowi = mysql_fetch_array($resultsi); // Use the result $qualities = array( 'charming', 'sense_of_humour', 'loyal', 'honest', 'attractive', 'optimistical', 'realistic', 'sexy', 'ambitious', 'visionary', 'quiet', 'conservative', 'tolerant', 'curious', 'selfconfident', 'athletic', 'attentive', 'shy', 'sociable', 'dominant', 'creative', 'active', 'passive', 'omesticated', 'friendly', 'sympathetic', 'fond_of_children', 'fond_of_animals', 'intelligent', 'romantic', 'talkative', 'joyful', 'humble', 'modest', 'caring', 'respectful', 'generous', 'thoughtful', 'down_to_earth', 'sensitive', 'professional', 'business_minded', 'solvent', 'determined', 'successful' ); while ($r=mysql_fetch_array($sql)) { $i = 0; foreach ($qualities as $quality) { if ($rowi['partner_'.$quality] == '1' && $r[$quality] == '1') $i++; } $tmp = array( 'id' => $r['id'], 'introduction_title'=> $r['introduction_title'], 'image_1'=> $r['image_1'], 'body_type'=> $r['body_type'], 'occupation'=> $r['occupation'], 'sdate'=> $r['sdate'], 'age'=> $r['age'], 'personality'=> $r['personality'], 'birthday'=> $r['birthday'], 'username'=> $r['username'], 'match'=> $i); array_push($result, $tmp); } // pass the results to the template $smarty->assign('result', $result); PHP: Cheers, Adam