title: Search form with a drop down list
body: <p>I have a search form where I have to search by Category which is a drop down list.There are 2 tables called members and categories.In categories table there are two fields as ID and Name(this Name field stores the name of the category like bank,hospital..).members table there is a field called Category which has the ID of the category which is same as the categories table ID value(Category field in members table is a foreign key).</p>
  
  <p>Here is the code for the drop down list</p>
  
  <pre><code>&lt;?php if($_GET['level']==2){ ?&gt;
          Category&lt;select name="Cat" style="display:inline-block"&gt;
          &lt;option&gt;&lt;/option&gt;
          &lt;?php $rs=mysql_query("SELECT ID,Name FROM categories ORDER BY Name"); 
          while($rc=mysql_fetch_array($rs)){
              ?&gt;
              &lt;option value="&lt;?php echo $rc[ID]; ?&gt;" 
              &lt;? echo $_POST['Cat'];?&gt;
              &lt;?php if($_POST['Cat']==$rc[ID])
                       echo 'selected'; ?&gt; &gt;
              &lt;?php echo $rc['Name']; ?&gt;&lt;/option&gt;
              &lt;?php } ?&gt;
              &lt;/select&gt;
          &lt;?php } ?&gt;
  </code></pre>
  
  <p>I have several palces where I don't  understand in this code.</p>
  
  <ol>
  <li>What's the use of <code>value="&lt;?php echo $rc[ID]"</code>.It is supposed to echo what I just input in the text box right?But $rc[ID] refers to a value from 1,2,3,4,5 but for the values in the drop down list it doesn't show numbers.So why echo this?</li>
  <li><code>$_POST['Cat']</code> doesn't refer to anything in the database right because I don't have such field.It has to do with <code>&lt;form name="Cat"&gt;</code>. How does this <code>$_POST['Cat']</code> gets values which should be integers in order to see a matching with <code>$rc[ID]</code>.But how does it get integer values because all I am inputting is from the drop down list a particular name.</li>
  <li>What's the use of "<code>echo selected</code>"?Is it there to be used when a matching is found then the option tag becomes <code>&lt;option selected&gt;</code> so that this value pops to the top of the list</li>
  </ol>