php - How to input a value from a drop down list into an SQL statement -


i obtain value selected drop down box. has entries database using jquery.

i add value drop down box sql statement query.

i tried using submit button work struggled.

any appreciated.

here option box:

<select id="combobox">                             <?php                                 echo '<option class="option">type/select room</option>';                                 while ($row = $res->fetchrow()) {                                     $code = $row['roomcode'];                                     $titles[] = $row['park'];                                     echo '<option class="option" name="codedrop">'.$code.'</option>';  

here sql statement trying add data into:

$resql = "select * 'rooms' 'roomcode' '$code%'";                                     $res1 = mysql_query($resql); 

html

0) add form tags around select attribute method="post"

1) set name attribute select element

2) set value attribute each option field

example code:

<form action="" method="post">     <select id="combobox" name="combobox">       <option class="option" name="codedrop" value="' . $code . '"></option>       <option class="option" name="codedrop" value="' . $code . '"></option>       <option class="option" name="codedrop" value="' . $code . '"></option>     </select> </form> 

php

accessing value of chosen option in php once user has submitted form:

<?php    $_post['nameofselectelement']; ?> 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -