title: MySQL query only returning first value in a loop
body: <p>I'm trying to convert usernames to their respective userid, but for some reason only the first item in the array is being converted. The rest are just nulls in the resulting array. I can enter the same name 3 times and still, only the first element of the array is converted.</p>
  
  <p>Say I try to convert the following array to their userid's</p>
  
  <pre><code>$users = [1 =&gt; test1, 2 =&gt; test2, 3 =&gt; test3]
  </code></pre>
  
  <p>The resulting array is</p>
  
  <pre><code>$users = [1 =&gt; 1, 2 =&gt; , 3 =&gt; ]
  </code></pre>
  
  <p>This is the loop that looks up the userid</p>
  
  <pre><code>foreach($user_list as $user){
      array_push($user_id_list,$convert-&gt;userid_lookup($user));
  }
  </code></pre>
  
  <p>here's the conversion function</p>
  
  <pre><code>function userid_lookup($username){
      echo $username //each name appears here
      $lookup = mysql_query("select userid from users where username = '$username' ");
      $result = mysql_fetch_array($lookup);
      echo $result['userid']; //only the first element's id appears
     return $result['userid'];
  }
  </code></pre>
  
  <p>Why would only the first element be converted? I know each item is being processed because when I echo each item, they display.</p>