listing options in the selected tag through a SQL query in PHP -


this first question in exciting website :)

ok...

i wana retrive value tag php... options in selected tag function php lists options saperate php files called functions.php

see function below functions.php

function list_brand (){   $sql = "select brand laptop          ";   $query = mysql_query($sql) or die (mysql_error());    if ($query) {      //echo 'success'; <-- testing function functinality       while ($query_row = mysql_fetch_assoc($query)) {            $brand = $query_row['brand'];             echo '<option value="brand">'.$brand.'</option>';      }         } else {echo 'fiald if';} } 

and below selected tag:

<select id="test" onchange="document.getelementbyid('text_content').value=this.options[this.selectedindex].text">           <option value="select">select brand</option>                       <?php                         list_brand();                       ?> </select> <input type="hidden" name="brand_text" id="text_content" value="" /> 

now question have 2 other selected tags should list options depending on selected option in first selected tag , should list thorough sql query

below full html code:

<form action="comparison.php" method="get"> <table width="80%" border="0" align="center" cellpadding="1" cellspacing="2">   <tr>     <td colspan="2">lap 1</td>     <td colspan="2">lap 2</td>   </tr>   <tr>     <td width="19%">brand</td>     <td width="31%"><select><option value="brand1">==select brand==</option>                     <?php                       list_brand();                     ?>                     </select></td>     <td width="19%">brand</td>     <td width="31%"><select name="brand2"><option value="brand2">==select brand==</option>                     <?php                       list_brand();                     ?>                     </select></td>   </tr>   <tr>     <td width="19">model</td>     <td width="31"><select><option value="model1">==select model==</option></select></td>      <td width="19">model</td>     <td width="31"><select><option value="model2">==select model==</option></select></td>   </tr>   <tr>     <td width="19">partnumber</td>     <td width="31"><select><option value="pn1">==select partnumber==</option></select></td>      <td width="19">partnumber</td>     <td width="31"><select><option value="pn2">==select partnumber==</option></select></td>   </tr>   <tr>     <td height="453" colspan="2">&nbsp;</td>     <td colspan="2">&nbsp;</td>   </tr> </table> </form> 

this it. had put 2 functions on onchange 1 assigning selected value , other submit page can refresh...

 <form name="index" action="" method="get">   <select id="brand" onchange="document.getelementbyid('brand_content').value=this.options[this.selectedindex].text; document.index.submit();">           <option value="">==select brand==</option>                       <?php                         list_brand();                       ?>   </select>   <input type="hidden" name="brand_text" id="brand_content" value="" />  <?php       $brand = $_get['brand_text'];       if (isset($brand)){        }  else {echo 'no brand selected';} ?>   <br>   <select id="model" onchange="document.getelementbyid('model_content').value=this.options[this.selectedindex].text; document.index.submit(); ">>   <option value="model1">==select model==</option>   <?php        list_model($brand);   ?>   </select>   <input type="hidden" name="model_text" id="model_content" value=""  </form> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -