title: Joomla Mysql query in foreach loop
body: <p>I'm trying to build a simple select list in Joomla 2.5 with php and mysql, but I've got a problem: it doesen't load the options name... are there any error?</p>
  
  <pre><code>&lt;?php
  $db = JFactory::getDBO();
  $query = $db-&gt;getQuery(true);
  $query-&gt;select('optValue');
  $query-&gt;from('#__sobipro_field_option');
  $query-&gt;where("fid='38'");
  $db-&gt;setQuery((string)$query);
  $results = $db-&gt;loadObjectList();
  if ($results){
  echo "&lt;select&gt;";
   foreach($results as $result){
      foreach($result as $value) {
      $query-&gt;select('sValue');
      $query-&gt;from('#__sobipro_language');
      $query-&gt;where("fid='38' and language='it-IT' and sKey='".$value."'");
      $db-&gt;setQuery((string)$query);
      $name = $db-&gt;loadResult();
      echo "&lt;option value=\"$value\"&gt;".$name."&lt;/option&gt;";
      }
      }
  
      echo "&lt;/select&gt;";
  }
  else {
  echo 'Error';
  }
  ?&gt;
  </code></pre>