php - Dropdown Menu to Query Database -


first of apologize if dumb question - i'm starting pick php/mysql skills. i'm making dropdown form 3 dropdowns. want able trigger query form. select part type, make, model hit submit , table of results displayed.

i have form populated 3 arrays , when hit submit, can echo key of each selected item page:

    echo '<form action="dbbrowse.php" method="post">';      $mak = array (0 => 'make', 'ford', 'freightliner', 'peterbilt', 'sterling', 'mack', 'international', 'kenworth', 'volvo');     $mod = array (0 => 'model', 'argosy', 'midliner');     $p = array (0 => 'part', 'radiator', 'charge air cooler', 'ac');                                echo '<select name="drop1">';     foreach ($p $key => $value) {     echo "<option value=\"$key\">     $value</option>\n";      }       echo '</select>';         echo '<select name="drop2">';     foreach ($mak $key => $value) {     echo "<option value=\"$key\">     $value</option>\n";        }      echo '<select/>';        echo '<select name="drop3">';     foreach ($mod $key => $value)  {     echo "<option value=\"$key\">     $value</option>\n";        }      echo '<select/>';     echo '</form>';               //echo keys of selection     echo $_post['drop1'];     echo "<br />";     echo $_post['drop2'];     echo "<br />";     echo $_post['drop3'];             //these echo 1, 1, 3 etc. page 

where i'm getting lost i'm looking take selected options , insert them query this:

     $dropsearch = mysql_query('select * parts part= "$parttypevar" . ,  make = "$maketypevar" . , model = "$modeltypevar"');                  $parttypevar being corresponding value key being returned array.         

i'm driving myself crazy trying figure out how make happen. want expand further being able create mysql statement values selected make day right now. understand concept of needs happen i'm unsure of how accomplish it. or pushes in right direction appreciated.

first of all, have delete . char in sql query, there's no need use , of course assign correct values variables.

$parttypevar = mysql_real_escape_string($_post['$drop1']); $maketypevar = mysql_real_escape_string($_post['$drop2']); $modeltypevar = mysql_real_escape_string($_post['$drop3']);  $dropsearch = mysql_query('select * parts part= "$parttypevar" , make = "$maketypevar" , model = "$modeltypevar"'); 

i assuming that's correct order of variables.

i hope help!


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -