javascript - how to pass value to query in same page in php? -


i have dropdown box

<select> <option value=1>a</option> <option value=2>b</option> </select> 

in php code have query

<?php $sql='select * table id='.'selectoptionvalue' ?> 

i need pass selected value in clause (id=selectoptionvalue) how pass value in clause dropdown...any help..

thanks,

nawaz

i think below code resolve problem

 <?php      $sql = 'select * table id = '.$_get['selected'].' ' ;     ?>     <select name="selected" id="model">         <option value="">select</option>         <option value="1" <?php if($_get['selected'] == 1) echo 'selected';?> >a</option>         <option value="2"  <?php if($_get['selected'] == 2) echo 'selected';?>>b</option>     </select>     <script type="text/javascript">         var select = document.getelementbyid("model");         select.onchange = function(){             var selectedstring = select.options[select.selectedindex].value;             window.location = "http://localhost/stack/stack-q/2.php?selected="+selectedstring;         }     </script> 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -