Hi guys. Thanks for your help. Still haven't quite got it working.
$result = mysql_query("select *, IF(state LIKE '%.$mystate.%', 1, 0) AS _sortcol, DATE_FORMAT(fecha, \"%d-%m-%Y\") AS mydate from datebase
WHERE fecha >= $ultimos_fecha AND
nivel > '0'
order by _sortcol desc, $orderby desc
limit $lim,$numero_anuncios")
or die (mysql_error() );
This gives me no error, but the order by doesn't work, they still come up jumbled,
and this
$result = mysql_query("select *, DATE_FORMAT(fecha, \"%d-%m-%Y\") AS mydate from tenercoche_privado
WHERE fecha >= $ultimos_fecha AND
nivel > '0'
order by $orderby desc case when state LIKE '%".$mystate."%' then 0 else 1 end
limit $lim,$numero_anuncios")
or die (mysql_error() );
The use of LIKE is compulsory in my case, and I also have to order by another parameter selected by the user. (Price, date of ad etc).
Anyone spot the error?
Many thanks.
Jon