But i want to add a search bar for price (or maybe a drop down menu with different price ranges)
i have 2 search bars and right now its working if you enter a product and a price but its will only work if you enter the exact price
for example i search guitar and price of 500 - if thats in the database it will display.
But i want it to display any products that are close to the price (thats why i thought a drop down menu would be better but i'm not sure how what would work)
here my code:
Code: Select all
<?php
mysql_connect ( 'localhost', 'root', "", 'k00127082')
or die (mysql_error());mysql_select_db ("k00127082");
$term = $_POST['term'];
$secondterm = $_POST['secondterm'];
$sql = mysql_query("select * from products where product_name like '%$term%' AND price like '%$secondterm%' ");
?>
<table width="600" border="1">
<tr>
<th>Product Name </th>
<th>Description </th>
<th>Quantity on Hand</th>
<th>Price</th>
<th>Image</th>
</tr>
<?php
while ($row = mysql_fetch_array($sql))
{
$propID = $row['id'];
$product_name = $row['product_name'];
$product_description = $row['product_description'];
$quantity_on_hand = $row['quantity_on_hand'];
$price = $row['price'];
$image = $row['image'];
$formattedPrice = number_format($price, 2, '.', ',');
echo '<tr>';
echo "<td>$product_name</td>";
echo "<td>$product_description</td>";
echo "<td>$quantity_on_hand</td>";
echo "<td>€$formattedPrice</td>";
//echo "<td><a href='datadrilldown.php?propID=$propID'><img src='images/$image' /></td>";
echo "<td><a href='datadrilldown.php?propID=$propID'>$image</a></td>";
echo '<tr>';
}
echo '</table>';
if(!$row = mysql_fetch_array($sql))
{
echo 'We do not have that product';
}
?>