Select Box Option values not shown in all select boxes
<p>The following is a code to select categories from table and list it in select box, This is done to edit earlier selected categories.</p>

<p>First query($sqlscat) simply takes the corresponding cid and name of categories to list.</p>

<p>Second query($sqlsubcat) selects a unique cid number from seller profile,the same cid will be in profile categories too.</p>

<p>Third query selects corresponding category and its cid which user selected and stored earlier.</p>

<p>Here every thing is working properly until when the second select box is loaded. When loading first select box all its $scatrows['title_spa'] are listed. But when second select box is shown only one result ie $selrow['title_spa'] is shown. ie $scatrows['title_spa'] are not shown in later select boxes. </p>

<p>It clearly means that during loading off remaining select boxes it is not entering the while loop-  while($scatrows = $ilance->db->fetch_array($sqlscat)) , why is it so...??</p>

<p>Hope the question is elaborated properly....</p>

<pre><code>   $sqlscat = $ilance-&gt;db-&gt;query("SELECT
                  cid,title_spa 
                  FROM " . DB_PREFIX . "categories 
                   WHERE parentid = '0'
                    ");

        $sqlsubcat = $ilance-&gt;db-&gt;query("SELECT
                cid FROM " . DB_PREFIX . "seller_profile 
                WHERE userid = '" . $uid . "'");
            $subrow = $ilance-&gt;db-&gt;fetch_array($sqlsubcat);

        $sqlselcat = $ilance-&gt;db-&gt;query("SELECT
                        q.title_spa,q.cid
                        FROM " . DB_PREFIX . "categories q
                        LEFT JOIN " . DB_PREFIX . "profile_categories a ON (q.cid = a.cid)
                        WHERE a.user_id = '" . $uid . "' GROUP BY q.cid
                        ");
                        $catrows=$ilance-&gt;db-&gt;num_rows($sqlselcat);


            if ($ilance-&gt;db-&gt;num_rows($sqlselcat) &gt; 0)  
            {   
             $subcat .='&lt;div class="sub_catsel"&gt;';  
            while($selrow = $ilance-&gt;db-&gt;fetch_array($sqlselcat))
            {

               if($selrow['cid']!=$subrow['cid'])
               {  
               $subcat .='&lt;h2&gt;&lt;select id="sucat" name="catego[]" &gt;';
               $subcat .='&lt;option value="'.$selrow['cid'].'" selected &gt;'.$selrow['title_spa'].'&lt;/option&gt;';

               while($scatrows = $ilance-&gt;db-&gt;fetch_array($sqlscat))
               {

                      $subcat .='&lt;option value="'.$scatrows['cid'].'" &gt;'.$scatrows['title_spa'].'&lt;/option&gt;'; 

                }
                    $subcat .='&lt;/select&gt;&lt;/h2&gt;';
                }   
             }
              $subcat .='&lt;/div&gt;';
              }
</code></pre>
