Problem with selected subcategory when editing Category items
<p>I want to item's subcatory selected when editing category:</p>

<pre><code>&lt;?php
  function categoryFormEdit()
 {
  $ID = $_GET['id'];
  $query = "SELECT * FROM category WHERE id= $ID";
  $result = mysql_query($query);
  $row = mysql_fetch_array($result);
  $subcat = $row['subcat'];
  $text = '&lt;div class="form"&gt;
        &lt;h2&gt;Add new category&lt;/h2&gt;
          &lt;form method="post" action="?page=editCategory"&gt;
              &lt;ul&gt;
                  &lt;li&gt;&lt;label&gt;Kategori&lt;/label&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;input type="text" class="inp" name="cname" value="' . $row['name'] . '"&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;label&gt; Aç&amp;#305;klama&lt;/label&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;textarea class="inx" rows="10" cols="40" name="kabst"&gt;' . $row['description'] . '&lt;/textarea&gt;&lt;/li&gt;
                  &lt;li&gt;
                    &lt;select class="ins" name="kselect"&gt;
                      &lt;option value="1"&gt;Aktif&lt;/option&gt;
                      &lt;option value="0"&gt;Pasif&lt;/option&gt;
                    &lt;/select&gt;
                  &lt;/li&gt;
                  &lt;li&gt;Üst kategorisi&lt;/li&gt;
                  &lt;li&gt;
                    &lt;select class="ins" name="subsl"&gt;';
                        $s = "SELECT * FROM category";
                        $q = mysql_query($s);
                        while ($r = mysql_fetch_assoc($q)) {
                            $text .= '&lt;option value="' . $r['id'] . '" ' . sQuery() . '&gt;' . $r['name'] . '&lt;/option&gt;';
                        }
                    $text .= '&lt;/select&gt;
                 &lt;/li&gt;

                     &lt;li&gt;Home page:&lt;/li&gt; 
                     &lt;li&gt;
                       &lt;input type="radio" value="1" name="kradio"&gt; Active
                       &lt;input type="radio" value="0" name="kradio"&gt; YPassive
                     &lt;/li&gt;
                     &lt;li&gt;&lt;input type="submit" class="int" value="ekle" name="ksubmit"&gt;&lt;/li&gt;
                &lt;/ul&gt;
            &lt;/form&gt;
        &lt;/div&gt;';
  return $text;
 }

 function sQuery()
 {
    if ($r['id'] == $subcat) {
      $t = "selected";
    } 
    else {

      $t = "";
    }
   return $t;
  }
?&gt;
</code></pre>

<p>With above code there is not selected item. What is wrong in my script?
Thanks in advance</p>
