$query = "SELECT a.*, cc.name AS category, dd.ezcity AS proploc, ee.name AS statename, ff.name AS cnname, ss.dealer_name AS propseller, u.name AS editor"

. "\n FROM #__ezrealty AS a"

. "\n LEFT JOIN #__ezrealty_catg AS cc ON cc.id = a.cid"

. "\n LEFT JOIN #__ezrealty_locality AS dd ON dd.id = a.locid"

. "\n LEFT JOIN #__ezrealty_state AS ee ON ee.id = a.stid"

. "\n LEFT JOIN #__ezrealty_country AS ff ON ff.id = a.cnid"

. "\n LEFT JOIN #__ezrealty_profile AS ss ON ss.mid = a.owner"

. "\n LEFT JOIN #__users AS u ON u.id = a.checked_out"

. ( count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : "")

. if ( isset ($_POST['idSearch']) ) 

    . { " WHERE a.id = " . $_POST['idSearch']  ; }

. "\n ORDER BY ". $order

. "\n LIMIT $pageNav->limitstart, $pageNav->limit"

;

i don obtain the wrong syntax here :( ,, also it keep return exactly the same error unpredicted T_IF

Take away the . (point) prior to the if-statement. Since the if-statement itself is not a string you cannot just concatenate it.

Avoid this:

. if (condition) { value_if_true; }

Rather do that:

. (condition ? value_if_true : value_if_false)

if are only able to be an argument: you're utilizing it being an expression. It does not return anything, also it can't be used within another statement.

You are able to, however, make use of the ternary operator to complete exactly this:

. ( isset ($_POST['idSearch']) ?  " WHERE a.id = " . $_POST['idSearch'] : '') 

This states "if $_POST['idSearch'] is placed, include that string, otherwise, add the empty string.

Note that you ought to really review your code, because there's a glaring SQL injection in only the code that I have published above. Anybody could execute arbitrary code in your database. Make certain to sanitise your input and, ideally, adopt prepared claims and parameterised queries to create your code safer.

In my opinion you need to turn this into an evil ternary operator:

. (count ...)
. (isset($_POST['idSearch']) ? ' WHERE a.id = ' . $_POST['idSearch'] : '')
. "\n ORDER BY" ...