title: mysql PHP query question
body: <p>Ok, i have a problem here...</p>
  
  <p>I am sending values of drop down lists via ajax to this PHP file.</p>
  
  <p>Now I want to search a mysql database using these values, which I have managed to do, BUT, only if I set the values to something...</p>
  
  <p>Take a look:</p>
  
  <pre><code>     $query = "SELECT * FROM cars_db WHERE price BETWEEN '$cars_price_from' AND '$cars_price_to' AND year BETWEEN '$cars_year_from' AND '$cars_year_to' AND mileage BETWEEN '$cars_mileage_from' AND '$cars_mileage_to' AND gearbox = '$cars_gearbox' AND fuel = '$cars_fuel'";
  </code></pre>
  
  <p>now, what if the user doesnt select any "price_from" or "year_from"... The fields are only optional, so if the user doesnt enter any "price from" or "year from", then the user wants ALL cars to show...</p>
  
  <p>Do I have to write a query statement for each case or is there another way?</p>