$result = mysql_query('SELECT DISTINCT sec from tags WHERE main = $r ORDER BY sec'); Code (markup): It's not returning a result. $r is set.
Take variables out of the quotes and use double quotes (and single quotes for strings). If r is an integer/float etc: $result = mysql_query("SELECT DISTINCT sec from tags WHERE main = ".$r." ORDER BY sec"); if it's a string/date etc: $result = mysql_query("SELECT DISTINCT sec from tags WHERE main = '".$r."' ORDER BY sec"); if $r is a set (like (1,2,3,4,5)) $result = mysql_query("SELECT DISTINCT sec from tags WHERE main IN ".$r." ORDER BY sec");
yep, that was it. Changed the code to $result = mysql_query("SELECT DISTINCT sec from tags WHERE main = '".$r."' ORDER BY sec"); Code (markup): and it worked. Thanks nico