witam smile.gif

mały problem ... poniższy kod pobiera z bazy danych, z dwóch tabel (obszary i tematy) powiązane ze sobą dane i wrzuca je do dwóch powiązanych ze sobą pól setect,
i tu pojawia się problem nie do każdego obszaru przypisany jest temat ... chciałbym aby po wybraniu w pierwszym polu select obszaru, do którego nie został przypisany żaden temat wyślietlało sie "brak tematów" ...

na nazie zrobiłem to tak, że do tabeli z tematami dodałem odpowiednią liczbę rekordów "brak tematów" i powiązałem je z odpowiednimi obszarami ... efekt jaki odpowiedni, ale nie o to chodzi sad.gif


Kod
<form name="doublecombo">
           <p>
           <select name="obszar" size="1" onChange="redirect(this.options.selectedIndex)">
           <?php
           $connection = mysql_connect("127.0.0.1", "root", "");
                               mysql_select_db("bla");
                               mysql_query("SET NAMES 'latin2'");
                              
           $query = "SELECT id, naz_obszar_kont FROM obszar_kont";
           $result = @mysql_query($query);
           $num = mysql_num_rows($result);
           if ($num > 0) {
               while ($row = mysql_fetch_array($result)) {
                   echo "<option value=\"".$row[0]."\">".$row[1]."</option>\n";
               }
           }
           ?>
           </select>
          
           <select name="temat">
           </select>
          
           <input type="button" name="test" value="Wczytaj!" onClick="go()">
           </p>
           <?php
           echo '
           <script>
           <!--
          
           var groups=document.doublecombo.obszar.options.length
           var group=new Array(groups)
           for (i=0; i<groups; i++)
           group[i]=new Array()
           ';
          
           $result3 = mysql_query("SELECT * FROM obszar_kont");
           while ($row3 = mysql_fetch_assoc($result3)) {
           $result4 = mysql_query("SELECT * FROM temat_kont WHERE id_obszar_kont='".$row3['id']."'");
          
           $iii=0;
          
           while ($row4 = mysql_fetch_assoc($result4) AND $i= mysql_num_rows($result3)) {
           echo "
           group['".($row3['id'])."']['".$iii."']= new Option('".$row4['naz_temat_kont']."','".$row4['id']."')
           ";
           $iii++;
           }
           }
           echo '
           var temp=document.doublecombo.temat
          
           function redirect(x){
           for (m=temp.options.length-1;m>0;m--)
           temp.options[m]=null
           for (i=0;i<group[x].length;i++){
           temp.options[i]=new Option(group[x][i].text,group[x][i].value)
           }
           temp.options[0].selected=true
           }
          
           function go(){
           location=temp.options[temp.selectedIndex].value
           }
           //-->
           </script>
           ';
           ?>