What is wrong with this:
HTML:
<select name="multipleSelect" multiple>
<option value="value_1">Value 1
<option value="value_2">Value 2
<option value="value_N"> Value N
</select>
...
<input type='text' name='maxprice'>
PHP:
($maxprice) ? $maxprice = strip_tags(trim($maxprice)) : $maxprice = 999;
$min_price1 = 1000;
$max_price1 = 2000;
$min_price2 = 1000;
$max_price2 = 2000;
$max_priceN = 1000;
$max_priceN = 2000;
for ($i=0; $i<sizeof($multipleSelect); i++) {
switch ($multipleSelect[$i]) {
case "value_1":
$min_price1 = 1;
$max_price1 = $maxprice;
break;
case "value_2":
$min_price2 = 1;
$max_price2 = $maxprice;
break;
case "value_N":
$min_priceN = 1;
$max_priceN = $maxprice;
}
}
...
SELECT * FROM table WHERE
(value1 BETWEEN '$min_price1' AND '$max_price1')
OR (value2 BETWEEN '$min_price2' AND '$max_price2')
OR (valueN BETWEEN '$min_priceN' AND '$max_priceN')
That is,
I would like to make a search form where the right products are shown depending on which maximum price is stated by the user. If one product is not in stock, its price is set to 0 in the database. No products are more than 999 dollars.
However, when I try to perform a search, no results are shown. Can anyone firgure out why?
Thanks in advance,
Nico