listing options in the selected tag through a SQL query in PHP
<p>this is my very first question in this exciting website :)</p>

<p>ok...</p>

<p>i wana retrive a value from  tag into PHP... the options in this selected tag is a function from PHP which lists those options from a saperate php files called functions.php</p>

<p>see the function below from functions.php</p>

<pre><code>function list_brand (){
  $sql = "SELECT brand FROM laptop
         ";
  $query = mysql_query($sql) or die (mysql_error());

  if ($query) {
     //echo 'success'; &lt;-- testing the function functinality

     while ($query_row = mysql_fetch_assoc($query)) {
           $brand = $query_row['brand'];

           echo '&lt;option value="brand"&gt;'.$brand.'&lt;/option&gt;';
     }      
  } else {echo 'fiald if';}
}
</code></pre>

<p>and below is the selected tag:</p>

<pre><code>&lt;select id="test" onchange="document.getElementById('text_content').value=this.options[this.selectedIndex].text"&gt;
          &lt;option value="select"&gt;SELECT BRAND&lt;/option&gt;
                      &lt;?php
                        list_brand();
                      ?&gt;
&lt;/select&gt;
&lt;input type="hidden" name="brand_text" id="text_content" value="" /&gt;
</code></pre>

<p>now my question is that i have two other selected tags that should list the options depending on that selected option in the first selected tag and that it should list thorough a SQL query</p>

<p>below is my full html code:</p>

<pre><code>&lt;form action="comparison.php" method="GET"&gt;
&lt;table width="80%" border="0" align="center" cellpadding="1" cellspacing="2"&gt;
  &lt;tr&gt;
    &lt;td colspan="2"&gt;Lap 1&lt;/td&gt;
    &lt;td colspan="2"&gt;Lap 2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td width="19%"&gt;Brand&lt;/td&gt;
    &lt;td width="31%"&gt;&lt;select&gt;&lt;option value="brand1"&gt;==SELECT BRAND==&lt;/option&gt;
                    &lt;?php
                      list_brand();
                    ?&gt;
                    &lt;/select&gt;&lt;/td&gt;
    &lt;td width="19%"&gt;Brand&lt;/td&gt;
    &lt;td width="31%"&gt;&lt;select name="brand2"&gt;&lt;option value="brand2"&gt;==SELECT BRAND==&lt;/option&gt;
                    &lt;?php
                      list_brand();
                    ?&gt;
                    &lt;/select&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td width="19"&gt;Model&lt;/td&gt;
    &lt;td width="31"&gt;&lt;select&gt;&lt;option value="model1"&gt;==SELECT MODEL==&lt;/option&gt;&lt;/select&gt;&lt;/td&gt;

    &lt;td width="19"&gt;Model&lt;/td&gt;
    &lt;td width="31"&gt;&lt;select&gt;&lt;option value="model2"&gt;==SELECT MODEL==&lt;/option&gt;&lt;/select&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td width="19"&gt;Partnumber&lt;/td&gt;
    &lt;td width="31"&gt;&lt;select&gt;&lt;option value="pn1"&gt;==SELECT PARTNUMBER==&lt;/option&gt;&lt;/select&gt;&lt;/td&gt;

    &lt;td width="19"&gt;Partnumber&lt;/td&gt;
    &lt;td width="31"&gt;&lt;select&gt;&lt;option value="pn2"&gt;==SELECT PARTNUMBER==&lt;/option&gt;&lt;/select&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td height="453" colspan="2"&gt;&amp;nbsp;&lt;/td&gt;
    &lt;td colspan="2"&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
</code></pre>
