I was recomended to use the code as bellow to check if one of the condition not selected for example what if somebody will select just Mark=toyota and will leave empty Model and Year.

PHP Code:
$where = array();
$whereclause '';

if (!empty(
$mark)) {
$where[] = "a.mark = '$mark'";
if (!empty(
$model)) {
$where[] = "a.model = '$model'";
if (!empty(
$year)) {
$where[] = "a.year = $year";
if (
count($where 0)) {
$whereclause join(' AND '$where);

PHP Code:
$result mysql_query("SELECT * FROM `add_new_car` AS a INNER JOIN `image_add_car` AS b ON
                                 a.id_add_car = b.user_id WHERE (b.user_id, b.id_image_add_car) IN (SELECT user_id, MIN(id_image_add_car)
FROM image_add_car GROUP BY user_id) AND "
.$whereclause." ORDER BY a.id_add_car"); 

Mark=toyota Model=Prado Year=2013

But why when I chose just Mark it doesn't gives me any result but at least together with Model=Prado it works without selecting Year

Thank you