I am trying to create a dropdown list search to search my database in PHP and my SQL. So far I have been able to create a simple text search which brings back the results needed when I type them into the search box. But I want to be able to select an option from the dropdown list instead of typing it in.
Here is my search.php code...
<?php
mysql_connect ("localhost", "root","") or die (mysql_error());
mysql_select_db ("schoolsni");
$term = $_POST['term'];
$sql = mysql_query("SELECT * FROM product WHERE model LIKE '%$term%'");
while ($row = mysql_fetch_array($sql)){
echo 'Product ID '.$row['product_id'];
echo '<br/> Model: '.$row['model'];
echo '<br/> quantity: '.$row['quantity'];
echo '<br/><br/>';
}
?>
And here is my HTML code...
<div class="UFcol1">
<form action="search.php" method="post">
<select name="term">
<option value="product">product</option>
<option value="product1">product 1</option>
<option value="product3">product 3</option>
<option value="product4">product 4</option>
</select>
<input type="submit" name="submit" value="Submit" />
</form>
</div>