I have a SQL table with model year from and model year to, in filter I need to select only one parameter year and I want to get all models which are in that year gap.
<?php
$make= $_POST['make'];
$model= $_POST['model'];
$from= $_POST['year'];
if(!empty($make)){$mysql="and `make`='$make'";}
if(!empty($model)){$mysql.=" and `model`='$model'";}
if(!empty($from)){$mysql.=" and `from`='$from'";}
$spec=$mysqli->query("SELECT * FROM `cars` WHERE (from <= to AND to>=
from) AND id!='' $mysql ");
while($r = $spec->fetch_object()){
echo "$r->id $r->make $r->model $r->from";
echo"</br>";
?>
With this code I can get only year from. How to get all models with year including from and to? (example: if I choose Audi 100 1990, I need to get all Audi 100 which were made in 1990). Take a look at my sql table example.