Forum Moderators: coopster
Remember, that php is only server based language. So what you have is two ways to do this:
I
1. Select filter
2. Submit the form
3. Calculate
4. Connect to db and display the data
or
II
1. Connect to db and write the data to js
2. Select filter and filter data with js
3. Calculate with js
4. Display with js
To accomplish first task:
form.html:
<form action="process.php" method="POST"><select name="filter[]"><option value="blue">Blue</option>...</select><select name="filter[]">....<input type="submit" name="action" value="submited"></form>
<?php
if($_POST["action"]!= "submited")
{header("Location: form.html");//redirect
die("Wrong form");}
$filter = "WHERE ";
$select = array("color", "type");//what is each select
foreach($_POST["filter"] as $key=>$value) {
$filter .= $select[$key] . "='" . $value ."' AND ";}
$filter = substr($filter, 0, -5);//gets rid of last AND
$sql = "SELECT product, sthelse FROM table $filter ORDER by color LIMIT 0, 20";
...//get the db and echo the values
?>