title: Why loop break in first loop
body: <p>My Goal is to list all lesser user based on role weight, example if user U1 has role of R1 with the weight of 10, and U2 has R2 with weight of 2 and U3 has R3 with weight 5. The output will be (U1, U2) (U1, U3) (U3, U2) and (U2, Null). List all the lesser user on the first row but it seems that in breaks in first loop. Here's my code thank you</p>
  
  <pre><code> &lt;?php
   $uids = array(8,9,10,11,12,13,14,15);
   $result = db_query("SELECT u.uid, u.rid, r.name, r.weight FROM {role} r INNER JOIN      {users_roles} u ON u.rid = r.rid WHERE u.uid IN (:uids)", array(':uids' =&gt; $uids));
   $i = 0;
   for ($i = 0; $role = $result-&gt;fetchAssoc(); ++$i) {
      print $role['uid'].',';
         foreach($result as $urole) {
           if ($role['weight'] &gt; $urole-&gt;weight) {
             echo '(' . $role['uid'] . ',' . $urole-&gt;uid  . ')';        
           } 
        }
     }
  ?&gt;
  </code></pre>