$getusers = $db->query_read(" SELECT " . TABLE_PREFIX . "user.username, " . TABLE_PREFIX . "userfield.field66 FROM " . TABLE_PREFIX . "user LEFT JOIN " . TABLE_PREFIX . "userfield ON " . TABLE_PREFIX . "user.userid=" . TABLE_PREFIX . "userfield.userid WHERE " . TABLE_PREFIX . "userfield.field66 = '" . $variable . "' "); while ($user = $db->fetch_array($getusers)) { // code will run for every result returned // $user contains your resultset for each result returned // (i think this is what you want?) $allusers[] = $user; } // $allusers is now an array containing each result