I'm trying to do the following query: $db_connect = mysql_connect($sqlhostname,$login,$password); $base_selection = mysql_select_db($base,$db_connect); $query = "SELECT DISTINCT * FROM xp_topics WHERE artist_count='artist' AND topictext LIKE 'A%' ORDER BY artist_count ASC limit 0,5"; $req = mysql_query($query); $res = mysql_num_rows($req); if ($res == 0)
{ echo "</p> <p><b>N/A</b>";} else { while($row = mysql_fetch_array($req)) $query2 = "SELECT SUM(1) FROM xp_stories,xp_topics WHERE xp_topics.topicid = xp_stories_topicid AND xp_topics.topictext = '$topictest'"; $numtopic = mysql_query($query2) or die("Select Failed!"); $numtopic = mysql_fetch_array($numtopic); { extract($row); echo ("$topictext $numtopic[0]<br> "); } } ?> Which should return a name and then count how many topics by that person. If I leave out the query2 statement I do get a list of name, but I can't get query2 to work.