Re: count

From: Date: Thu, 10 Jan 2002 13:22:41 +0000
Subject: Re: count
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-15597@lists.php.net to get a copy of this message
Barry, I can't see where you've created $topictest. Maybe, just before you define $queyr2, you should have the line $topictest = $row[ "topcitext"]; I also think xp_stories_topicid should be xp_stories.topicid Try echo 'ing $query2 and see what is printed. Hope this helps, and that I've not missed something else. Miles Thompson At 02:05 AM 1/11/2002 +1300, Barry Rumsey wrote:
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.


« previous php.db (#15597) next »