I have the next code but I am not getting the desired result by using ORDER BY:
// OrderBy WHERE Conditions
if ($sort_by == "0") $sortby_condition = "ORDER BY mv_user_ranking.ranking_date DESC ";
if ($sort_by == "1") $sortby_condition = "ORDER BY mv_user_info.age DESC ";
if ($sort_by == "2") $sortby_condition = "ORDER BY mv_user_info.sex DESC ";
$query ="SELECT * FROM mv_user_info
LEFT JOIN mv_user_lang_interested ON mv_user_lang_interested.uid = mv_user_info.uid
LEFT JOIN mv_user_disponibility ON mv_user_disponibility.uid = mv_user_info.uid
LEFT JOIN mv_user_ranking ON mv_user_ranking.uid = mv_user_info.uid
WHERE country ='$country' AND city = '$city' AND
mv_user_lang_interested.english = '1' AND
mv_user_lang_interested.english_level = '2' AND
mv_user_info.uid != '$uid'"
.$sortby_condition.
"LIMIT 0, 50";
echo $query;
$result = mysql_query($query) or die(mysql_error());
What I am doing wrong?
$sort_bydoesn't have the value you expect. Inspect its value.$sort_byto see what the value is. You could change it to anif/elseif/else, to give a default sort in case the value is not0,1,2